One of my favorite Nintendo NES games was Dragon Warrior. It made you finish the game. At level 30, you couldn’t gain any more experience points. The mentor wizard person (because there’s always a mentor wizard person) would tell you, “Aren’t you strong enough to defeat the DragonLord?”
As I debated whether I knew enough to write a tip about configuring your git diff and merge tools, I ask myself “Aren’t you strong enough to defeat the git diff merge config tool?!”
More about the game at bottom of post…
Let’s start by engaging in epic battle with the git-scm instructions. I’m going to assume you’ve installed p4merge. Yes I know there are others, but for now, I’m going to follow these instructions. The journey to 3rd degree black belt starts with a single punch.
These are the two lines I get stuck on:
$ git config --global merge.tool extMerge $ git config --global mergetool.extMerge.cmd \ 'extMerge "$BASE" "$LOCAL" "$REMOTE" "$MERGED"'
so why need two lines? Perhaps I’m not recalling enough of my shell programming or the translation fails over to Windows? The instructions say
Set up a merge wrapper script named
extMergethat calls your binary with all the arguments provided
so `extMerge` is a variable. But why can’t you have it all on the same line?? What am I missing?
and also, what is “mergetool”? is it yet another variable? and how does it differ from merge.tool?
I’ll assume you have p4merge installed here in C:\Program Files\Perforce
Thanks to these for Windows we can setup p4merge as our merge and diff tools using Git Shell (I’m using Git Bash)
$ git config –global diff.tool p4merge
$ git config –global difftool.p4merge.path ‘C:\Program Files\Perforce\p4merge.exe’
$ git config –global merge.tool p4merge
$ git config –global mergetool.p4merge.path ‘C:\Program Files\Perforce\p4merge.exe’
Now let’s create a merge conflict, but this time, I’m going to keep my heart rate low when the (master|MERGING) appears! Btw I called my branch `conflicting` just because.
now you can type in git mergetool
I’m not going to go over p4merge, but I think the “error” showing for the base file is because p4merge is trying to do a 3-way merge, but only has 2 files. Don’t quote me on this.
After modifying the resulting myfile1.text and hitting save in p4merge and closing it, we’re back to the merge conflict state. This used to freak me out because git didn’t “move on”. But now I know what to do!
You can do a `git status` to verify where you are at.
Perfect! We’re done with myfile1.txt and it is staged. Since it is staged, we can simply commit it via `git commit -m “my merge message”`
And boom! I’ve now done epic battle with one of my most feared Git foes.
The most memorable aspect of the game was the ending… but not for the reasons you’d think. The game had their basic “hero” ending, but it also offered a twist. Before going into battle with the Dragonlord, he’d ask you to join him in being evil and taking over the universe. If you said yes, the game would “freeze” and IIRC, it would erase your saved game! I’ve never heard of another game doing this. There’s the “did you give a dog a sandwich?” story, but not a “come join the dark side” option destroying your saved game!