我需要在我的旧 Git 中使用与以下类似的设置才能使用 difftool。设置不完全相同,因为我不小心删除了旧的 .gitconfig。
[merge]
tool=opendiff
[mergetool]
tool=opendiff
[difftool]
difftool=opendiff
我家里有一个空的 .gitconfig。 我仍然可以使用 opendiff -工具。 这是一个惊喜,因为这应该是不可能的。
Git 的 difftool 设置在内部如何工作?
最佳答案
你可以看到一个complete setup using mergetool and difftool here .
如果设置似乎仍然有效,可能是因为它已在全局或您的帐户中设置,因为 git-config 将在三个文件中搜索配置选项:
$GIT_DIR/config
存储库特定的配置文件。 (文件名当然是相对于存储库根目录,而不是工作目录。)
~/.gitconfig
用户特定的配置文件。也称为 Git 安装位置的“全局”配置文件:
$(prefix)/etc/gitconfig
系统范围的配置文件。
Git 会在您输入“git config
”时保存用户信息:
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 withGIT_DIR
andGIT_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.
TheGIT_CONFIG
environment variable has a similar effect, but you can specify any filename you want.
可能是您在之前的安装中设置了该环境变量?
GIT_CONFIG
从给定文件而不是 .git/config
中获取配置。使用“--global
”选项将其强制为 ~/.gitconfig
。使用“--system
”选项将其强制为 $(prefix)/etc/gitconfig
。
注意:对于 Mac OsX,$(prefix)
应该是 /usr/local
(如果您将 Git 安装为 described here)
make prefix=/usr/local all
sudo make prefix=/usr/local install
which git
关于git - 无法理解 Git 的 difftool 配置是如何设置的,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1063618/