无法理解如何设置Git的difftool配置 [英] Unable to understand how Git's difftool configs are set

查看:1116
本文介绍了无法理解如何设置Git的difftool配置的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要在旧版Git中使用类似的设置才能使用difftool。设置不完全一样,因为我偶然删除了旧的.gitconfig。

  [merge] 
工具= opendiff

[mergetool]
工具= opendiff

[difftool]
difftool = opendiff

我在家中有一个空的.gitconfig。
我仍​​然可以使用opendiff-tool。
这是一个惊喜,因为它应该是不可能的。



Git的difftool设置如何在内部工作?

解决方案

您可以看到在此处使用mergetool和difftool完成设置



如果该设置似乎仍处于活动状态,这可能是因为它已被全局设置或在您的帐户中设置,因为有三个文件,git-config将搜索配置选项:

  $ GIT_DIR / config 

存储库特定的配置文件。 (文件名当然是相对于版本库的根目录,而不是工作目录。)

 〜/ .gitconfig 

用户特定的配置文件。在您的Git安装位置也称为全局配置文件:

  $(前缀)/ etc / gitconfig 

全系统配置文件。




Git将用户信息保存在您输入' git config '时保存的位置:

git config手册页面


文件选项可以是 - system - global - file ,它指定将读取或写入值的位置。

默认值是假定配置文件为当前的仓库,.git / config,除非用 GIT_DIR GIT_CONFIG

另外定义。

您可以通过命令行选项或环境变量覆盖这些规则。 - global - system 选项将分别限制用于全局或系统范围文件的文件。
GIT_CONFIG 环境变量具有类似的效果,但您可以指定任何您想要的文件名。




可能你在之前的安装中设置了该环境变量吗?

  GIT_CONFIG 

从给定文件取代 .git / config 。使用 - 全局选项强制它为〜/ .gitconfig 。使用 - system 选项强制使用 $(前缀)/ etc / gitconfig

注意:对于Mac OSX, $(前缀)应该是 / usr / local (如果您将Git安装为此处描述的

  make prefix = / usr / local all 
sudo make prefix = / usr / local install
其中git


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

这篇关于无法理解如何设置Git的difftool配置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆