How to find out which Git config file is used and how to override settings?

泄露秘密 提交于 2019-12-05 00:27:42

How can I determine precisely which gitconfig file is being used by my Git bash client ?

You can use the --show-origin option

git config --list --show-origin

This will show the file from which each setting's value was taken.

Can I override settings in the Git config file being used ?

You can override settings from lower-precedence sources by putting the value you want to use instead in a higher-precedence source.

I've read your example, and I'm really not sure I get the question. If the proxy setting is in your global file, then as you already pointed out yourself you can override it by putting a value in the local file.

meagar

That would mean that Git works with all the settings in all the config files before applying the hierarchy rule.

Yes. The results are additive. Settings in each level are merged with the settings in the previous level. When both levels specify the same setting, the lower more specific setting overwrites the less specific one.

as git configuration documentation clearly states:

The .git/config file in each repository is used to store the configuration for that repository, and $HOME/.gitconfig is used to store a per-user configuration as fallback values for the .git/config file. The file /etc/gitconfig can be used to store a system-wide default configuration.

As for your second question,

And then, in the example above, if the proxy setting from global is being used together with the other settings in my local config file how can I override it?

Provide a more specific setting in the local config for the project.

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