2

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?

Léo Léopold Hertz 준영
  • 134,464
  • 179
  • 445
  • 697
  • Just updated my answer about git config files chosen when updating git settings. – VonC Jun 30 '09 at 14:34
  • Just updated my answer with value of prefix for Mac OsX – VonC Jun 30 '09 at 14:59
  • I have my git external diff tool setup documented in: http://stackoverflow.com/questions/267761/what-does-your-gitconfig-contain/596821#596821 This may be helpful. Let me know if you also would like the script that that answer contains as an exercise for the reader. I did that because it is pretty specific to Araxis Merge. – Mark Jul 01 '09 at 15:05
  • @Mark: Please, show me that the script which is specific to Araxis Merge. – Léo Léopold Hertz 준영 Jul 01 '09 at 17:19

2 Answers2

5

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
Community
  • 1
  • 1
VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
3

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.

Community
  • 1
  • 1
Jakub Narębski
  • 309,089
  • 65
  • 217
  • 230
  • +1. I tried to check in the script 'git-merge-tool' where that default auto-detection setting might take place, but did not find anything at first glance. Do you know if the auto-detection is scripted, or is within some git executable? – VonC Jun 30 '09 at 14:09
  • VonC's question is now at http://stackoverflow.com/questions/1064103/is-gits-auto-detection-scripted-or-is-it-within-some-git-executable – Léo Léopold Hertz 준영 Jun 30 '09 at 14:53
  • @VonC: Check 'guess_merge_tool' function in 'git-mergetool--lib' (in "git --exec-dir"). – Jakub Narębski Jun 30 '09 at 16:11