Merge conflicts
Git stops and asks
A branch is a separate line of commits (save points), and merging combines one branch into another. Usually it just works.
But today Kai types git merge feature/hard-mode and Git prints:
CONFLICT (content): Merge conflict in balance.jsonAutomatic merge failed; fix conflicts and then commit the result.
Don't panic. Nothing is broken or lost. Git just needs a human decision.
Why conflicts happen
Git merges line by line. If Kai changed line 4 of a file and Remy changed line 9, Git combines both with no fuss. That covers most merges.
A merge conflict happens when both branches changed the same lines, or one person deleted a file the other edited. Git can't know which version is right, so it stops and asks.
Conflicts can also appear during git pull, because pull is a download plus a merge.
Quick check
If Kai only edits ship.js and Remy only edits shop.js, merging their branches causes a conflict.
- True
- False
Show the answer
False
Different files means different lines, so Git combines both changes by itself. Conflicts only happen when both change the same lines.
The conflict markers
Git writes both versions into the file, between conflict markers:
<<<<<<< HEAD"sprigHealth": 12,======="sprigHealth": 8,>>>>>>> feature/hard-mode
The top part is your current branch. HEAD means "where I am now". The bottom part is the incoming branch. Your job: edit the file so it holds the right final version, and delete all three marker lines.
Choose or combine
- Keep currentKeep the HEAD version, delete the other.
- Keep incomingKeep the version from the other branch instead.
- CombineOften the best answer uses both. Ask whoever made the other change what they meant.
There are three ways out. Many code editors show buttons for them right above the markers.
Fix the conflict
1{2<<<<<<< HEAD3 "sprigHealth": 12,4=======5 "sprigHealth": 8,6>>>>>>> feature/hard-mode7 "snailSpeed": 18}
The team agrees normal mode keeps Sprig at 12 health. Hard mode will get its own setting later. What should lines 2 to 6 become?
- Just "sprigHealth": 12, with all three marker lines deleted
- Leave them as they are, the game will pick one
- Just "sprigHealth": 8, keeping the ======= line
Show the answer
Just "sprigHealth": 12, with all three marker lines deleted
Keep the agreed value and remove every marker line. Markers left in balance.json make it broken JSON, so Garden Defense couldn't load its numbers at all.
Test, then finish
Before finishing, test: run the game and play the part that changed. A file can look fine and still be wrong. One leftover ======= in a JSON file crashes the game on load.
Then tell Git the conflict is solved and finish the merge:
git add balance.jsongit commit -m "Merge hard mode, keep Sprig at 12"
Want to back out halfway? git merge --abort cancels the merge and puts everything back as it was.
Quick check
Once the conflict markers are gone, the merge must be correct, so there's no need to play the game.
- True
- False
Show the answer
False
Removing markers only makes the file readable. You might have kept the wrong value, or two changes might clash in a way only playing reveals. Always test before committing.
Fewer conflicts
- Pull oftengit pull at the start of every session. The newer your copy, the fewer surprises.
- Short branchesMerge a branch within a day or two. Branches that live for weeks drift far apart.
- Small commitsSmall changes are easier for Git to combine and easier for you to understand.
- Talk firstAbout to change balance.json? Say so on the task board, so two people don't edit it at once.
AI can help, you decide
An AI agent can help with conflicts. Ask Claude Opus 5.5: "Explain both sides of this conflict in balance.json and suggest a fix."
But you still read its answer and play the game, because only the team knows which number was meant to win.
Bolt says: Next lesson: pull requests, where the team checks every change before it is merged.
Fact-checked 9 October 2026
- Git docs: git merge (how conflicts are presented) git-scm.com
- Pro Git: Basic merge conflicts git-scm.com
- GitHub Docs: Resolving a merge conflict using the command line docs.github.com