为什么Git config list(total)与system + global + local不一样 [英] Why Git config list (total) is not the same as system + global + local

查看:1352
本文介绍了为什么Git config list(total)与system + global + local不一样的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在Windows上的Git 2.6.3上,为什么这个命令会导致:

  git config --list 

与其他人不一样:

  git config --list --system 
git config --list --global
git config --list --local

第一个列出的选项比其他选项总和多一些。我已重定向到文件和kdiff比较,并有差异。



根据要求,这是 git config --list ,而不是在system / global / local分组:

  core.symlinks = false 
core .autocrlf = true
color.diff = auto
color.status = auto
color.branch = auto
color.interactive = true
pack.packsizelimit = 2g
help.format = html
http.sslcainfo = C:/ Program Files(x86)/Git/mingw32/ssl/certs/ca-bundle.crt
sendemail.smtpserver = / bin / msmtp .exe
diff.astextplain.textconv = astextplain
rebase.autosquash = true

上面列出的那个配置(不是在system / global / local)值保存在哪里? TL; DR : C:\Users\All Users\Git\config

请参阅


C:\程序数据\Git ,我看到额外的值:

  C:\程序数据\Git>更多配置
[core]
symlinks = false
autocrlf = true
[color]
diff = auto
status = auto
branch = auto
interactive = true
[pack]
packSizeLimit = 2g
[help]
format = html
[http]
sslCAInfo = C:/ Program Files / Git / mingw64 / ssl / certs / ca-bundle.crt
[sendemail]
smtpserver = / bin / msmtp.exe

[diffastextplain]
textconv = astextplain
[rebase]
autosquash = true

正如 ProgramData 文件夹在Windows?,该文件夹是 All Users 中的一个:

  C:\ Users \所有用户\Git> dir 
驱动器C中的卷没有标签。

C:\ Users \ All Users\Git

23/10/2015 16:36< DIR> 。
23/10/2015 16:36< DIR> ..
23/10/2015 16:36 350 config


On Git 2.6.3 on Windows, why this command result:

git config --list

Is not the same as this others:

git config --list --system
git config --list --global
git config --list --local

The first one has a few more options listed than the sum of the others. I have redirected to files and kdiff compare and there are differences.

As requested this is the values there are in git config --list and not in the system/global/local grouped:

core.symlinks=false
core.autocrlf=true
color.diff=auto
color.status=auto
color.branch=auto
color.interactive=true
pack.packsizelimit=2g
help.format=html
http.sslcainfo=C:/Program Files (x86)/Git/mingw32/ssl/certs/ca-bundle.crt
sendemail.smtpserver=/bin/msmtp.exe
diff.astextplain.textconv=astextplain
rebase.autosquash=true

Where are that config quoted above (not in system/global/local) values saved?

解决方案

TL;DR: C:\Users\All Users\Git\config.
See git-for-windows PR 470

On Windows, as there is no central /etc/ directory, there is yet another config file (located at %PROGRAMDATA%\Git\config), intended to contain settings for all Git-related software running on the machine.
Consequently, this config file takes an even lower precedence than the $(prefix)/etc/gitconfig file.

You can check that (with git 2.8+, March 2016), by typing

git config --list --show-origin

See "Where do the settings in my Git configuration come from?"


As mentioned in git config FILES, git is looking for values (or default values if not found) of configs in 3 places (outside the git repo itself)

$(prefix)/etc/gitconfig

System-wide configuration file.

$XDG_CONFIG_HOME/git/config

Second user-specific configuration file.
If $XDG_CONFIG_HOME is not set or empty, $HOME/.config/git/config will be used. Any single-valued variable set in this file will be overwritten by whatever is in ~/.gitconfig. It is a good idea not to create this file if you sometimes use older versions of Git, as support for this file was added fairly recently.

~/.gitconfig

User-specific configuration file. Also called "global" configuration file.

But a quick process monitor mentions a fourth place (again, outside a git repo itself)

In C:\ProgramData\Git, I see the extra values:

C:\ProgramData\Git>more config
[core]
        symlinks = false
        autocrlf = true
[color]
        diff = auto
        status = auto
        branch = auto
        interactive = true
[pack]
        packSizeLimit = 2g
[help]
        format = html
[http]
        sslCAInfo = C:/Program Files/Git/mingw64/ssl/certs/ca-bundle.crt
[sendemail]
        smtpserver = /bin/msmtp.exe

[diff "astextplain"]
        textconv = astextplain
[rebase]
        autosquash = true

As mentioned in "What is the significance of the ProgramData folder in Windows?", that folder is the one from All Users:

C:\Users\All Users\Git>dir
 Volume in drive C has no label.

 Directory of C:\Users\All Users\Git

23/10/2015  16:36    <DIR>          .
23/10/2015  16:36    <DIR>          ..
23/10/2015  16:36               350 config

这篇关于为什么Git config list(total)与system + global + local不一样的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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