Branches and merging · Lesson 7 of 15
Resolve merge conflicts
Read markers, choose the right result, and know when to abort.
12 minutes2 games
A conflict is not a failure; it is a question for a human when two branches change the same area. <<<<<<< marks the current side, ======= divides it, and >>>>>>> marks the incoming side.
merge reports a conflict
Understand both intents
Edit and remove markers
add then commit
Git
git init -q -b main echo "blue" > color.txt git add color.txt git commit -q -m "Base" git switch -q -c feature echo "green" > color.txt git commit -q -am "Green" git switch -q main echo "navy" > color.txt git commit -q -am "Navy" git merge feature cat color.txt
Write the intended final version, test it, then git add file to mark it resolved and commit. Use git merge --abort if the merge was a mistake.
Quick question
What marks a file resolved?
Exercise
Create a conflict in answer.txt, resolve it as both, commit and print the file.
Expected output:
Auto-merging answer.txt CONFLICT (content): Merge conflict in answer.txt Automatic merge failed; fix conflicts and then commit the result. both
Git
git init -q -b main echo "base" > answer.txt git add answer.txt git commit -q -m "Base"
Learn more from
Played 0 of 2 games
Sign in to save your progress and earn XP.