Git Merge Conflict
A merge conflict happens when two branches change the same lines of a file. Git cannot know which version to keep, so it stops and asks you.
Git marks the conflict in the file with <<<<<<<, ======= and >>>>>>>. Edit the file to keep what you want, remove the markers, then git add the file and commit.
Get a conflict
git merge conflict-demo
Auto-merging index.html
CONFLICT (content): Merge conflict in index.html
Automatic merge failed; fix conflicts and then commit the result.
cat index.html
...
<body>
<<<<<<< HEAD
<h1>Hello W3Schools!</h1>
=======
<h1>Hello Git!</h1>
>>>>>>> conflict-demo
...
Fix it and finish the merge
Edit index.html so it has only the line you want, then:
git add index.html
git commit -m "Merged conflict-demo, kept W3Schools heading"
[main 6682b7d] Merged conflict-demo, kept W3Schools heading
Give Up the Merge
Run git merge --abort to stop the merge and go back to how things were before it.