覆盖.gitconfig用户文件中的git config --system(git config --global) [英] override git config --system in .gitconfig user file ( git config --global )

查看:423
本文介绍了覆盖.gitconfig用户文件中的git config --system(git config --global)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在系统配置文件中拥有该文件(但它也可以包含在 git config include.path =/ path / to / defaultconfig中)我想重置以前设置的一些值。特别是,默认配置文件包含 diff.external = git-diff-wrapper

em>在他/她的全局和本地设置中覆盖一个配置值。



但是没有简单的方法可以在较低配置中停用一项设置文件。

甚至将它设置为通常会产生意想不到的后果。非常话题已于2010年4月进行了讨论

例如,取消激活发送电子邮件选项:


应该纠正这个问题,使用没有值的unset是一个可怕的,可怕的黑客攻击。

git-send-email 应该被纠正为不仅检查是否存在值来自配置或命令行选项,但也是它是理智的(即如果我们说
smtpuser =0不是我们需要担心支持的话)。


对于任何设置都是如此: diff.c#run_diff_cmd() 函数会尝试运行一个外部diff如果它检测到了 diff.external )。

  if (!strcmp(var,diff.external))
return git_config_string(& external_diff_cmd_cfg,var,value);

导致:

  if(pgm){
run_external_diff(pgm,name,other,one,two,xfrm_msg,
complete_rewrite);
return;





$ b

所以没有简单的方法来阻止系统宽差异外部确保这些用户引用不同的git系统安装路径(意思是不同的系统设置)。


I have that file in a system wide configuration (but it can also be included with git config include.path="/path/to/defaultconfig" I would like to reset some values previously setted.

In particular, the default config file contains diff.external = git-diff-wrapper, and I would like to deactivate it for some user

解决方案

If it is a system wide config, each user can override a config value in his/her global and local settings.

But there is no easy way to "deactivate" a setting in a lower config file.
Even set it to "" generally has unintended consequences. That very topic was discussed in April 2010.

For instance, deactivating the send-email option:

True, after thinking a bit about this using no value to unset is a horrible, horrible hack.
git-send-email should be corrected to not only check that there is value from config or command line option, but also that it is sane (i.e. non-empty, or simply true-ish if we say that smtpuser = "0" is not something we need to worry about supporting).

That would be true for any setting: the diff.c#run_diff_cmd() function will attempt to run an external diff if it has detected and diff.external value (even "").

if (!strcmp(var, "diff.external"))
  return git_config_string(&external_diff_cmd_cfg, var, value);

leads to:

if (pgm) {
  run_external_diff(pgm, name, other, one, two, xfrm_msg,
  complete_rewrite);
  return;
}

So there is no easy way to block a system wide diff external, except by making sure those users reference a different git system installation path (meaning a different system setting).

这篇关于覆盖.gitconfig用户文件中的git config --system(git config --global)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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