Git on Windows: How do you set up a mergetool?
I've tried msysGit and Git on Cygwin. Both work just fine in and of themselves and both run gitk and git-gui perfectly.
Now how the heck do I configure a mergetool? (Vimdiff works on Cygwin, but preferably I would like something a little more user-friendly for some of our Windows-loving coworkers.)
To follow-up on Charles Bailey's answer, here's my git setup that's using p4merge (free cross-platform 3way merge tool); tested on msys Git (Windows) install:
git config --global merge.tool p4merge
git config --global mergetool.p4merge.cmd 'p4merge.exe "$BASE" "$LOCAL" "$REMOTE" "$MERGED"'
or, from a windows cmd.exe shell, the second line becomes :
git config --global mergetool.p4merge.cmd "p4merge.exe "$BASE" "$LOCAL" "$REMOTE" "$MERGED""
The changes (relative to Charles Bailey):
Download: http://www.perforce.com/product/components/perforce-visual-merge-and-diff-tools
EDIT (Feb 2014)
As pointed out by @Gregory Pakosz, latest msys git now "natively" supports p4merge (tested on 1.8.5.2.msysgit.0).
You can display list of supported tools by running:
git mergetool --tool-help
You should see p4merge in either available or valid list. If not, please update your git.
If p4merge was listed as available, it is in your PATH and you only have to set merge.tool:
git config --global merge.tool p4merge
If it was listed as valid, you have to define mergetool.p4merge.path in addition to merge.tool:
git config --global mergetool.p4merge.path c:/Users/my-login/AppData/Local/Perforce/p4merge.exe
~
should expand to current user's home directory (so in theory the path should be ~/AppData/Local/Perforce/p4merge.exe
), this did not work for me $LOCALAPPDATA/Perforce/p4merge.exe
), git does not seem to be expanding environment variables for paths (if you know how to get this working, please let me know or update this answer) setting mergetool.p4merge.cmd will not work anymore since Git has started trying to support p4merge, see libexec/git-core/git-mergetool--lib.so we just need to specify the mergetool path for git,for example the p4merge:
git config --global mergetool.p4merge.path 'C:Program FilesPerforcep4merge.exe'
git config --global merge.tool p4merge
Then it will work.
I'm using Portable Git on WinXP (works a treat!), and needed to resolve a conflict that came up in branching. Of all the gui's I checked, KDiff3 proved to be the most transparent to use.
But I found the instructions I needed to get it working in Windows in this blog post, instructions which differ slightly from the other approaches listed here. It basically amounted to adding these lines to my .gitconfig
file:
[merge]
tool = kdiff3
[mergetool "kdiff3"]
path = C:/YourPathToBinaryHere/KDiff3/kdiff3.exe
keepBackup = false
trustExitCode = false
Working nicely now!
链接地址: http://www.djcxy.com/p/7234.html