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
## main
2360b7a Main greeting f811e4e Base
The fix
Auto-merging greet.txt CONFLICT (content): Merge conflict in greet.txt Automatic merge failed; fix conflicts and then commit the result.
UU greet.txt
<<<<<<< HEAD Hello from main ======= Hello from feature >>>>>>> feature
Hello from main and feature
[main 1151dbe] Merge branch 'feature'
Check the result
* 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.