-
-
Save adilsoncarvalho/758776 to your computer and use it in GitHub Desktop.
#!/bin/sh | |
# | |
# This script will make WinMerge your default tool for diff and merge. | |
# It must run inside git bash (on Windows) | |
# | |
# | |
# If you experience path issues you should give a try to the gist | |
# created by markusobrist at https://gist.github.com/1010253 | |
# | |
# If your WinMerge is in other place then this one, please edit | |
WINMERGE_PATH="c:/Program Files/WinMerge" | |
WINMERGE_APP="WinMergeU.exe" | |
WINMERGE_OPTIONS="-u -e" | |
# | |
# Global setup | |
# | |
git config --global mergetool.prompt false | |
git config --global mergetool.keepBackup false | |
git config --global mergetool.keepTemporaries false | |
# | |
# Adding winmerge as a mergetool | |
# | |
git config --global merge.tool winmerge | |
git config --global mergetool.winmerge.name WinMerge | |
git config --global mergetool.winmerge.trustExitCode true | |
git config --global mergetool.winmerge.path "$WINMERGE_PATH" | |
git config --global mergetool.winmerge.cmd "$WINMERGE_APP $WINMERGE_OPTIONS -dl \"Local\" -dr \"Remote\" \$LOCAL \$REMOTE \$MERGED" | |
# | |
# Adding winmerge as a difftool | |
# | |
git config --global diff.tool winmerge | |
git config --global difftool.winmerge.name WinMerge | |
git config --global difftool.winmerge.trustExitCode true | |
git config --global difftool.winmerge.path "$WINMERGE_PATH" | |
git config --global difftool.winmerge.cmd "$WINMERGE_APP $WINMERGE_OPTIONS \$LOCAL \$REMOTE" |
Hi Adlison
Thanks for the quick reply!
I tried that, but the config file doesn't like the backslash. The only way it worked was by specifying a .sh file as cmd and adding the following there:
"C:/Program Files (x86)/WinMerge/WinMergeU.exe" -e -dl "Base" -dr "Mine" "$1" "$2" "$3" "$4"
Maybe the issue is also the "(x86)" or that it's windows 7. I really have no idea why your approach didn't work for me.
Anyways, thanks a lot for the help and the cool script!
for completions sake the entry in the gitconfig file:
cmd = ~/winmerge.sh $LOCAL $REMOTE $BASE $MERGED
That's great. Wouldn't you like to change my gist to preserve your solution? or if you create a new one give me the link to it
I forked your gist and added my changes here:
https://gist.github.com/1010253
Hope that's alright with you?
Hi @adilsoncarvalho and @MarkusObrist,
Very useful scripts, thanks to both of you. I fixed the spaces problem by adding the WinMerge directory to PATH.
I found a difference in the third parameters for the merge tool configuration in both versions:
@adilsoncarvalho: $LOCAL $REMOTE $MERGED
@MarkusObrist: $LOCAL $REMOTE $BASE $MERGED
I also think the forth parameter will be ignored by WinMerge.
Can you clarify?
I've always used it inside git bash on windows and I've never experienced the issue you mentioned.
What if you try "c:/Program\ Files/Winmerge" escaping the space?