Rebasing for Morons (with merge conflicts)
Rebasing for me used to be a little like flossing… You always hear that you should, but it’s just so easy not to.
Then you finally work up the guts or guilt yourself enough into trying, and WHAM… more merge conflicts than a Los Angeles freeway ramp during rush hour.
A member of my team took time to walk me through the process, so I thought I’d share that knowledge with anyone else who feels stupid for even asking.
The official git rebase docs are actually pretty great, so I’ll just try to summarize while blatantly stealing their graphics:
If we start with:
A---B---C topic / D---E---F---G master
git merge master - Merges
master branch into
A---B---C topic / / D---E---F---G master
git rebase master - Replays
topic’s commits on top of
A'--B'--C' topic / D---E---F---G master
Important to note that the commits are now
C'. They are not the *actual commits from the
topic branch, they are duplicate commits that are played on top of the master branch.
My teammate pointed me to KDiff3 as a merge tool, and I’m sure there are plenty of others out there. We’ll use KDiff3 for our example.
- Download & install the tool
- Add following to your global
[merge] tool = kdiff3 [mergetool "kdiff3"] path = "C:\\Program Files\\KDiff3\\kdiff3.exe"
Now, whenever you have a conflict to resolve, you can run:
git mergetool -y
and you’re off!