Merge Conflicts

How to resolve merge conflicts during rebase and merge — including binary/age-encrypted files where standard diff doesn’t work.

Binary File Conflicts (age-encrypted, images, etc.)

Binary files can’t be merged — you pick one version or the other.

During git pull --rebase

Conflict on an age-encrypted file
git pull --rebase
# CONFLICT (content): Merge conflict in email/outlook-tokens.json.age
# error: could not apply abc1234... commit message
Resolution — keep the remote (incoming) version
git checkout --theirs email/outlook-tokens.json.age
git add email/outlook-tokens.json.age
git rebase --continue
Resolution — keep your local version
git checkout --ours email/outlook-tokens.json.age
git add email/outlook-tokens.json.age
git rebase --continue
Abort — go back to before the rebase
git rebase --abort

--ours vs --theirs (confusing during rebase)

During rebase, the meaning is inverted from merge:
Context --ours --theirs

git merge

Your current branch

The branch being merged in

git rebase

The branch you’re rebasing onto (remote)

Your commits being replayed (local)

During git pull --rebase:

  • --theirs = your local changes (the commit being replayed)

  • --ours = the remote version (what you pulled)

This is counterintuitive. When in doubt, decrypt both and compare:

Compare before choosing
# See what the remote has
git show REBASE_HEAD:path/to/file.age > /dev/shm/theirs.age
age -d -i ~/.age/identities /dev/shm/theirs.age

# See what's currently checked out (remote during rebase)
age -d -i ~/.age/identities path/to/file.age

# Clean up
shred -n 10 -u /dev/shm/theirs.age

Text File Conflicts

Standard Resolution

View conflict markers
git diff --name-only --diff-filter=U    # List conflicted files
Edit the file — resolve markers manually
<<<<<<< HEAD
your version
=======
their version
>>>>>>> branch-name
Mark resolved and continue
git add resolved-file.txt
git rebase --continue    # or: git merge --continue

Accept One Side for All Conflicts

Accept all of theirs (during merge)
git checkout --theirs .
git add -A
Accept all of ours (during merge)
git checkout --ours .
git add -A

Prevention

Set default pull strategy to avoid the prompt
git config --global pull.rebase true
For repos with binary/encrypted files — always pull before editing
git pull --rebase && dsec edit d000 dev/network