I'm trying to use KDiff3 as a difftool in Git Bash on a Windows 8.1 system, and I'm admittedly pretty new to Git. I can't get KDiff3 to open when I try comparing a staged file to the committed file, and I'm confused about what to do about it. I found directions online for setting up KDiff3 as a merge tool, and I guessed that I needed to do something similar to set it up as a diff tool (I haven't been able to find sufficiently explicit directions for newbies for setting up the diff tool, which is why I'm here). This is what I did after downloading and installing KDiff3:
git config --global diff.tool kdiff3
git config --global difftool.kdiff3.cmd '"C:\\Program Files\\KDiff3\\kdiff3" $BASE $LOCAL $REMOTE -o $MERGED'
Git didn't spew any errors at me, so maybe that's correct? I completely admit that I don't understand the syntax here! Anyway, when I tried this:
git diff HEAD
I get this:
error: cannot spawn kdiff3: No such file or directory
external diff died, stopping at MyFile.R
I've looked around, and I see some references to people having similar problems when their $PATH wasn't set correctly. I don't really know what the $PATH is (and if someone could enlighten me, I'd be much obliged), but the path that I've got for KDiff3 (C:\Program Files\KDiff3\kidff3) is definitely where kdiff3.exe is located on my machine. Any suggestions?
Thanks in advance, and as I said, I'm new to Git, so if I haven't provided some critical piece of information, please let me know.
I suggest you give up your second line of configruation, as Git bash has already defined how to use kdiff3. (You can look at your installation of Git Bash. for example, in my path, I can find C:\Program Files (x86)\Git\libexec\git-core\mergetools\kdiff3, which is the configuration file for kdiff3). The only thing you need to do is to put kdiff3 in your PATH variable.
Use only your first line:
but NOT your second line:
To fix your already added config, try to edit your .gitconfig, under your GIT BASH
Find the section
[difftool "kdiff3"]
, and remove the line withcmd=
under that section. You may remove the whole section as well (i.e. also remove the line containing[difftool "kdiff3"]
Then add your path to kdiff3:
Double quote is needed because of the space between "Program" and "Files".
This PATH line can be added to your .bashrc or .bash_profile, depending on how you start your bash...
--- UPDATE ---
Correction: Since Git Bash uses Windows system defined environment variable 'PATH' + Windows user defined environment variable 'PATH'. The above PATH change is harder (using .bashrc, etc..). Just change Windows environment variables like this link, and/or this link