Git is strong and helpful - especially when you work in a team, different projects etc. It shows you a clean history, helps you to work save in branches, just pick the thing you want to use etc.
But sometimes - and that is completly normal - conflicts can happen. So things have to be fixed.
This is the cheat sheet for the terms of fixing things.
Conflict
A conflict happens when Git cannot automatically decide how changes should be combined.
For example, two branches changed the same lines differently.
Git may show:
<<<<<<< HEAD
current version
=======
incoming version
>>>>>>> commit-id
These are conflict markers.
Resolving the conflict means deciding what the final content should be and removing the markers.
SmartGit’s Conflict Solver provides a visual interface for doing this.
Remember: A conflict isn’t necessarily an error. Git is simply asking you to make a decision it cannot safely make itself.
Continue Rebase
A rebase can stop when Git encounters a conflict.
The workflow then becomes:
Rebase
↓
Conflict
↓
Resolve
↓
Continue Rebase
↓
Next commit
Don’t start another rebase after resolving the conflict. Continue the existing one.
Abort
Sometimes the best solution is to stop an operation and return to the previous state.
For example:
Abort Rebase cancels the ongoing rebase and restores the branch to its pre-rebase state.
Very useful when an experiment goes in the wrong direction.
Amend
Amend changes the most recent commit.
For example, you can:
- change its commit message
- add a forgotten file
- correct something in the commit
But remember:
Amending creates a new commit ID.
If the old commit has already been pushed, pushing the amended version may therefore require rewriting the remote history.
Author / Committer
A Git commit can contain information about both an author and a committer.
The author is the person who originally created the change.
The committer is the person who created the particular commit object.
Changing authorship on an existing commit rewrites that commit and therefore changes its commit ID.
Revert
Revert undoes a previous commit by creating another commit.
Suppose you have:
A -- B -- C
and C introduced a problem.
Reverting C doesn’t delete it. Instead Git creates something like:
A -- B -- C -- R
R contains the inverse of the changes introduced by C.
That’s why revert is especially useful for already shared history.
Revert = undo with history preserved.
Reset
Reset moves a branch pointer to another commit.
For example:
A -- B -- C -- D
↑
branch
Resetting to B can move the branch back:
A -- B -- C -- D
↑
branch
What happens to your files depends on whether you use a soft, mixed, or hard reset.
Important: Reset and Revert are fundamentally different.
Revert creates a new commit. Reset moves history.
Reflog
The reflog records where your local Git references – including HEAD – have pointed recently.
This can be extremely useful after accidentally:
- resetting a branch
- rebasing
- squashing
- moving HEAD
- losing sight of an old commit
Think of it as:
Git’s local “Where was I before?” log.
Even when a commit disappears from the normal branch graph after a rebase or squash, the reflog can often help you find it again.
One Git Rule Worth Remembering
Many seemingly strange Git situations become easier once you ask three questions:
- Where is HEAD? Which branch am I actually working on?
- What is local and what is remote?
Am I looking at
mainororigin/main? - Am I adding history or rewriting history?
Operations such as normal commits, merges, and reverts generally add history.
Operations such as rebase, squash, amend, and editing an existing commit generally rewrite history.
That distinction explains why Git sometimes accepts a normal push – and sometimes requires a force push.