Skip to content

Git — small conflicts ​

Advanced Resolve without panic.

When it happens ​

bash
git pull
# or
git merge origin/main
# or
git rebase origin/main

Git stops and marks conflicted files.

bash
git status

Resolve loop ​

  1. Open each conflicted file
  2. Find markers:
text
<<<<<<< HEAD
your side
=======
their side
>>>>>>> branch-name
  1. Edit to the correct final content (remove markers)
  2. Stage and continue:

Merge ​

bash
git add path/to/fixed-file
git commit          # completes the merge (editor opens)

Rebase ​

bash
git add path/to/fixed-file
git rebase --continue

Abort (back out) ​

bash
git merge --abort
git rebase --abort

Tools that help ​

bash
git mergetool
# or open in VS Code / JetBrains merge UI
code --merge ...

“I took all of theirs / ours” ​

bash
# during merge:
git checkout --ours path/to/file
git checkout --theirs path/to/file
git add path/to/file

WARNING

--ours / --theirs flip meaning during rebase vs merge. When unsure, open the file.

After a messy conflict ​

bash
git status
git diff --check          # leftover conflict markers?
rg '<<<<<<|======|>>>>>>' # if you have ripgrep