当使用 git config --global
设置时,它将写入哪个文件?
例子:
git config --global core.editor "blah"
我在这些地方找不到它:
C:\Program Files\Git\etc\gitconfig
C:\myapp\.git\config
我没有设置环境?
我的 Git 版本:1.6.5.1.1367.gcd48 – 在 Windows 7 上
最佳答案
2016 年更新:使用 git 2.8(2016 年 3 月),您可以简单地使用:
git config --list --show-origin
使用 Git 2.26(2020 年第一季度),您可以 add a --show-scope
option
git config --list --show-origin --show-scope
您将看到在何处设置了哪个配置。
参见“Where do the settings in my Git configuration come from?”
作为Stevoisiak指出in the comments ,
it will work with non-standard install locations. (i.e. Git Portable)
(比如最新的PortableGit-2.14.2-64-bit.7z.exe
,可以任意解压)
原始答案(2010 年)
来自 the docs :
--global
For writing options: write to global
~/.gitconfig
file rather than the repository.git/config
.
由于您使用的是 Git for Windows ,可能不清楚这对应于什么位置。但是如果你查看 etc/profile(在 C:\Program Files\Git
中),你会看到:
HOME="$HOMEDRIVE$HOMEPATH"
含义:
C:\Users\MyLogin
(在 Windows 7 上)
这意味着对于 Windows 7 中的 Git,该文件位于 C:\Users\MyLogin\.gitconfig
中。
关于git - 全局 git 配置数据存储在哪里?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2114111/