ShareYourGroupShareYourGroupGit Help

Fix a merge conflict

Git says CONFLICT and stopped the merge.

The problem

Git says CONFLICT and stopped the merge.

How the practice repository looked before

$ git status --short --branch
## main
$ git log --oneline -5
2360b7a Main greeting
f811e4e Base

The fix

$ git merge feature
Auto-merging greet.txt
CONFLICT (content): Merge conflict in greet.txt
Automatic merge failed; fix conflicts and then commit the result.
$ git status --short
UU greet.txt
$ cat greet.txt
<<<<<<< HEAD
Hello from main
=======
Hello from feature
>>>>>>> feature
$ edit greet.txt
Hello from main and feature
$ git add greet.txt
(no output: that is normal)
$ git commit --no-edit
[main 1151dbe] Merge branch 'feature'

Check the result

$ git log --oneline --graph
*   1151dbe Merge branch 'feature'
|\  
| * 9e6f7eb Feature greeting
* | 2360b7a Main greeting
|/  
* f811e4e Base

Why this works

When both branches changed the same lines, Git writes both versions into the file between <<<<<<<, ======= and >>>>>>> markers and waits. You edit the file to what it should be, remove the markers, git add it and commit. UU in the status means "both modified".

If this is not quite your case

To cancel the whole merge and go back, run git merge --abort. In big conflicts you can take one side of a file entirely with git checkout --ours <file> or git checkout --theirs <file> and then git add it; note that during a rebase the meaning of ours and theirs is swapped, which surprises many people.

Be careful: Search the file for the markers before you commit. A leftover <<<<<<< line is a common mistake.

This is an independent guide. It is not connected with the Git project, GitHub, GitLab or any company named here. Every command below was run on 14 November 2026 with the real program (git version 2.56.0.windows.4) in a new empty practice repository; the output shown is what it printed. Facts about options were read in the official Git documentation on 14 November 2026.