Unable to understand how Git's difftool configs are set

狂风中的少年 提交于 2019-11-28 02:14:50
VonC

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
Jakub Narębski

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.

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!