Skip to content

Instantly share code, notes, and snippets.

@adilsoncarvalho
Created December 29, 2010 17:24
Show Gist options
  • Star 9 You must be signed in to star a gist
  • Fork 6 You must be signed in to fork a gist
  • Save adilsoncarvalho/758776 to your computer and use it in GitHub Desktop.
Save adilsoncarvalho/758776 to your computer and use it in GitHub Desktop.
shell script that configures git to use WinMerge as the default tool to handle conflicts
#!/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"
@adilsoncarvalho
Copy link
Author

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

@MarkusObrist
Copy link

I forked your gist and added my changes here:
https://gist.github.com/1010253

Hope that's alright with you?

@fredym
Copy link

fredym commented Aug 9, 2013

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment