|
Git doesn’t come with a merge tool, but will gladly use
third party tools…
The Git Debate
The reoccurring debate on switching from svn to git is going on
again on the Ruby Core mailing list. Amoung the many objections to
git is that it doesn’t come with a nice merge tool. Perforce was held
up as an example of a tool that does merging right. Although I’m not
a big fan of perforce in general, the merge tool in perforce was one
of its two redeeming aspects.
Now You Can Have Your Cake and Eat it Too!
Although it is correct that git doesn’t come with a nice merge tool, it
is quite happy to use any merge tool that you have on hand. And since
Perforce’s merge tool is available free (from
here), you can
use p4merge with git.
Just add the following to your .gitconfig file in your home directory:
[merge]
summary = true
tool = "p4merge"
[mergetool "p4merge"]
cmd = /PATH/TO/p4merge \
"$PWD/$BASE" \
"$PWD/$LOCAL" \
"$PWD/$REMOTE" \
"$PWD/$MERGED"
keepBackup = false
trustExitCode = false
Now, whenever git complains that a conflict must be resolved, just
type:
git mergetool
When you are done resolving the merge conflicts, save the result from
p4merge and then quit the utility. If git has additional files that
need conflict resolution, it will restart p4merge with the next file.
Enjoy.
Interested in (not) Hearing about Git?
I’m doing a talk that’s not about git at the Ohio, Indiana, Northern
Kentucky PHP Users Group (yes indeed, that
acronym is OINK-PUG) on September 17th. Although the talk is
explicitly not about git, you will come away from the talk with a
much deeper understanding on what goes on behind the curtains with
using git.
If there are other local groups interested in not hearing about git,
feel free to contact me.
Update (6/Sep/09)
Several people have mentioned that it is not obvious where to get the
p4merge tool from the perforce page. Go to the Perforce
downloads page and click
on the proper platform choice under “The Perforce Visual Client”
section. When you download “P4V: The Visual Client”, you will get
both the P4V GUI application and the p4merge application.
Oops, Another Update (7/Sep/09)
I forgot that the shell script that runs p4merge is something you have
to create yourself. Here’s mine:
#!/bin/sh
/Applications/p4merge.app/Contents/Resources/launchp4merge $*
There are more detais Andy McIntosh’s site
comments
|