Getting Started Git Basics Merge conflicts
Merge conflicts
Learn why merge conflicts happen in Git and how to resolve them safely.
A merge conflict happens when Git cannot automatically combine two sets of changes.
For merge tool setup and integration details, see Diff and Merge Tools.
Why conflicts happen
Git can merge many changes automatically, but not all of them.
Conflicts usually happen when two lines of work changed the same part of a file in incompatible ways, and Git cannot safely decide which result is correct.
For example, conflicts often appear when:
- Two branches edit the same lines differently.
- One branch deletes a file that another branch modifies.
- A rebase tries to replay a commit onto code that has changed too much.
- A cherry-pick applies a commit whose context no longer matches cleanly.
Conflicts are normal
A conflict does not mean the repository is broken or that someone made a mistake.
It usually means Git needs a person to decide how two changes should fit together. In collaborative work, that is completely normal.
The important part is to resolve the conflict carefully rather than panic or guess.
What resolving a conflict means
Resolving a conflict means deciding what the final file should look like.
Sometimes that means:
- Keeping one side and discarding the other.
- Combining both sets of changes.
- Rewriting the affected section into a new final version.
After you resolve the file contents, you stage the resolved result so Git knows the conflict has been handled.
Merge conflict markers
When Git cannot merge a file automatically, it may place conflict markers directly into the file.
Those markers show the competing versions so you can inspect them and decide what the final content should be. Until the conflict is resolved and staged, Git treats that file as still unresolved.
Resolving conflicts in GitComet
GitComet helps by showing which files are in conflict and letting you inspect the differences that Git could not combine automatically.
A typical conflict resolution flow is:
- Review the conflicting file or diff.
- Decide what the final result should be.
- Edit the file until the conflict is resolved.
- Stage the resolved file.
- Continue the merge, rebase, or cherry-pick that was interrupted.
If you want dedicated merge tool setup details, use the Diff and Merge Tools guide.