QUICK ANSWERA merge conflict happens when two branches change the same lines of a file (or one deletes a file the other edits) and Git cannot decide which version to keep. Git marks the file with <<<<<<<, ======= and >>>>>>> sections. Open each conflicted file, keep the right code and delete the markers, then
git add the file and run git commit (for a merge) or git rebase --continue (for a rebase).
What the markers mean
<<<<<<< HEAD
timeout: 30
=======
timeout: 60
>>>>>>> feature/faster-retry Between <<<<<<< HEAD and ======= is your current branch's version. Between ======= and >>>>>>> is the incoming branch's version. The fix is to write the final version you want and delete all three marker lines.
Resolve it step by step
- See which files conflict:
git statuslists them under "both modified". - Open each file and search for
<<<<<<<. Decide: keep yours, keep theirs, or combine both. Talk to the other developer if you are not sure. - Delete every marker line, save the file, and run the tests or at least build it.
- Mark it resolved:
git add <file>. - Finish:
git commitfor a merge, orgit rebase --continuefor a rebase (repeat for each commit that conflicts). - Changed your mind?
git merge --abortorgit rebase --abortreturns everything to how it was before. - Push. If you rebased a branch you had already pushed, use
git push --force-with-lease, never plain--force.
Useful shortcuts
| Command | What it does |
|---|---|
git checkout --ours <file> | Keep your version of a whole file |
git checkout --theirs <file> | Keep the incoming version of a whole file |
git mergetool | Open a visual 3-way merge tool |
git diff --name-only --diff-filter=U | List only the conflicted files |
| VS Code "Accept Current / Incoming / Both" | Click to resolve each block |
Careful: during a rebase, "ours" and "theirs" are swapped (ours is the branch you are rebasing onto).
How to have fewer conflicts
- Pull or rebase on main often; small, short-lived branches conflict less.
- Keep pull requests small and merge them quickly.
- Agree on formatting (Prettier, Black, gofmt) so whitespace changes do not collide.
- Do not reorganise or reformat a whole file in the same PR as a feature change.
Questions
Is a merge conflict an error?
No. It is Git asking you to choose. Nothing is lost; both versions are in the file until you decide.
Merge or rebase to update my branch?
Both work. Rebase gives a cleaner history but rewrites your commits, so only rebase branches no one else is building on. Follow your team's rule.