I needed to use in my old Git similar settings to the following to be able use difftool. The settings are not exactly the same, since I by accident removed my old .gitconfig.
[merge]
tool=opendiff
[mergetool]
tool=opendiff
[difftool]
difftool=opendiff
I have an empty .gitconfig at Home.
I can use still the opendiff -tool.
This is a surprise, since it should be impossible.
How do Git's difftool settings work internally?
You can see a complete setup using mergetool and difftool here.
If the setting seems to still be active, it may be because it has been set globally or in your account, since there are three files where git-config will search for configuration options:
$GIT_DIR/config
Repository specific configuration file. (The filename is of course relative to the repository root, not the working directory.)
~/.gitconfig
User-specific configuration file. Also called "global" configuration file at your Git's installation location:
$(prefix)/etc/gitconfig
System-wide configuration file.
Git saves the user info wherever you say it to save when you type 'git config
':
From git config manual page:
The file-option can be one of --system
, --global
or --file
which specify where the values will be read from or written to.
The default is to assume the config file of the current repository, .git/config unless defined otherwise with GIT_DIR
and GIT_CONFIG
.
You can override these rules either by command line options or by environment variables. The --global
and the --system
options will limit the file used to the global or system-wide file respectively.
The GIT_CONFIG
environment variable has a similar effect, but you can specify any filename you want.
May be you had that environment variable set in your previous installation?
GIT_CONFIG
Take the configuration from the given file instead of .git/config
. Using the "--global
" option forces this to ~/.gitconfig
. Using the "--system
" option forces this to $(prefix)/etc/gitconfig
.
Note: for Mac OsX, $(prefix)
should be /usr/local
(if you installed Git as described here)
make prefix=/usr/local all
sudo make prefix=/usr/local install
which git
You have also (in addition to remembering about many places Git searches for configuration, as stated in response by VonC) to remember that both git-difftool and git-mergetool provide some autodetection / autodiscovery (in some fixed order of preference) of which tools you have available.
This might be why "git difftool" invokes opendiff on your computer.