Common questions in git

There are two ways to solve this problem:
1. Delete the last commit using the following command:
git reset HEAD^

2. applying your changes and stage it by git add ., then use this command:
git commit --amend

improtant note - after that you should use these commands:
git push --force --all
git push --force --tags

revert: Creates a new commit that undoes a previous commit
reset: Moves the branch pointer to a different commit, possibly changing files
for example:
A → B → C → D → E → F (HEAD is here)
after git revert E:
A → B → C → D → E → F → G (G = revert of E)
after git reset --hard D:
A → B → C → D (HEAD is here)

git merge and git rebase both integrate changes from one branch into another, but they do it differently. git merge creates a new merge commit that joins two branches together, preserving the full history and showing when branches diverged and merged. This is useful for collaborative workflows because it clearly documents how and when changes were combined. However, it can make the commit history more complex and cluttered, especially with many branches.
In contrast, git rebase rewrites history by moving your commits to the tip of another branch, creating a cleaner, linear history as if all work was done sequentially. This makes it easier to follow the project’s progress but changes commit IDs and can cause problems if used on shared branches. Rebasing is often preferred for solo work or before merging a feature branch into the main branch to keep history tidy.