Configuring Kdiff3 and Git with Cygwin (now with Spaces!)


Oh my word. I don’t know what else to say. This was waaaay harder than I thought it would be. The goal was to able to open up two files from different branches and see the changes between them. the git command “difftool” looked to be the secret sauce and everything was working great until I tried to diff a file with a space in the name. That’s when the wheels fell off.

Here’s the command I was running:

git difftool Release-15.5 Release-16.1 “Sample File.sql”

 

Okay here are some of the gotchas I ran into:

  1. git on cygwin uses its own .gitconfig. It does not use the one at the standard windows path (e.g. “C:\Users\psteffek\.gitconfig”). It uses the one at “C:\cygwin64\home\psteffek\.gitconfig”. And just in case this wasn’t obvious “psteffek” is my username. Replace it with yours.
  2. Paths or files with spaces in them make for trouble and need to be escaped.
  3. Use the command: git config –list
    This will help you confirm you are modifying the correct file.

Here’s what I ended up with and it seems to be working wonderfully 🙂

 

[diff]
tool = kdiff3	
[difftool "kdiff3"]
    cmd = \"C:/Program Files (x86)/KDiff3/kdiff3.exe\" \"$(cygpath -wla \"$LOCAL\")\" \"$(cygpath -wla \"$REMOTE\")\"
    trustExitCode = false
[merge]
tool = kdiff3
[mergetool "kdiff3"]
cmd = \"C:/Program Files (x86)/KDiff3/kdiff3.exe\" "$(cygpath -wla $LOCAL)" \"$(cygpath -wla \"$REMOTE\")\"
keepBackup = false
trustExitCode = false
[difftool]
	prompt = false

Here’s what I get when I run git config –list:
Git Cygwin Kdiff3 and spaces
If this helped you at all leave a comment and let me know. Especially let me know if you had to make any changes!


Leave a Reply

Your email address will not be published.