Merge Conflicts
When both branches change the same lines, Git stops and marks the file with <<<<<<<, ======= and >>>>>>>. Edit the file to the final text, git add it and commit. git merge --abort cancels.
Example
echo "colour: red" > s.txt; git add .; git commit -q -m "base"
git switch -q -c blue; echo "colour: blue" > s.txt; git commit -q -am "blue"
git switch -q main; echo "colour: green" > s.txt; git commit -q -am "green"
git merge blue >/dev/null 2>&1; git status -s
cat s.txt
echo "colour: teal" > s.txt
git add s.txt; git commit -q -m "Resolve"
git status -s | wc -lResult
UU s.txt <<<<<<< HEAD colour: green ======= colour: blue >>>>>>> blue 0
Exercise
Cancel a merge.
git merge Quiz Test
These free lessons are for learning. Join a full course for projects, mentor feedback and a verified certificate.