Friday, July 15, 2011

Setting up correct Git config parameters on Windows

So when configuring Git to run on Windows, I ran into an annoying thing that took me a bit to figure out.

When you configure Git via bash, specifying the config setting with git config --global yadayadayada was not properly linking to the editors, diff tools, etc. The reason was that the config file could not determine the location of the apps because quotes were either missing, or added to the config file without escape characters.

Here is the .gitconfig file:
[user]
 name = mkadlec
 email = kadlecmark@hotmail.com
[core]
 editor = \"C:/Program Files (x86)/Git/bin/git-core-editor.sh\"
 autocrlf = false
[merge]
 tool = kdiff3
[diff]
 tool = kdiff3
 guitool = kdiff3
[mergetool "kdiff3"]
 keepBackup = false
 trustExitCode = false
 path = \"c:/Program Files (x86)/KDiff3/kdiff3.exe\"
[difftool "kdiff3"]
 path = \"c:/Program Files (x86)/KDiff3/kdiff3.exe\"
 keepBackup = false
 trustExitCode = false
 cmd = \"c:/Program Files (x86)/KDiff3/kdiff3.exe\" \"$LOCAL\" \"$REMOTE\"
See? Look closely, you have to escape all the quotations, and wrap any file locations with quotes if they are not. Once configured, all is good!

2 comments:

Unknown said...

Did not work for me until after i changed it to this.
I'm using https://msysgit.github.io/ on windows 8.1

[merge]
tool = kdiff3
[diff]
tool = kdiff3
guitool = kdiff3
[mergetool "kdiff3"]
keepBackup = false
trustExitCode = false
path = "c:/Program Files/KDiff3/kdiff3.exe"
[difftool "kdiff3"]
path = "c:/Program Files/KDiff3/kdiff3.exe"
keepBackup = false
trustExitCode = false
cmd = "c:/Program Files/KDiff3/kdiff3.exe" "$LOCAL" "$REMOTE"

Matt Wanchap said...

Thanks, this really helped me out :)