If you want to see more comics like this, sign up for my saturday comics newsletter or browse more comics!
read the transcript!
use diff3
or zdiff3
to see the original version of the code
git config --global merge.conflictstyle diff3
This will add an extra section in the middle of your merge conflicts
if you get confused, merge (or cherry-pick) 1 commit at a time
This can make the conflicts smaller and easier to resolve!
git-imerge
is a tool to make this easier, though I haven’t tried it
use rerere to remember how you resolved a conflict during a rebase
git config --global rerere.enabled true
This means you won’t have to resolve the exact same conflict over and over again
git checkout --ours/theirs
can take all changes from one side
For example
git checkout --ours file.txt
will take the version of file.txt from the “ours” side of the merge
(though upsettingly the meaning of “ours” and “theirs” depends on whether you merged or rebased)
if you can’t tell which code comes from which branch, looking on the web can help
Illustration of an uncertain-looking stick figure with short curly hair.
person (thinking): I’ll just go to GitLab and see what file.txt
looks like on the main branch
git merge-tree
can check for merge conflicts without actually merging the branches
$ git merge-tree --write-tree
main mybranch
...
Auto-merging file.py
CONFLICT (content):
Merge conflict in file.py
Saturday Morning Comics!
Want another comic like this in your email every Saturday? Sign up here!