git - 全局 git 配置数据存储在哪里?

标签 git config

当使用 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/

相关文章:

git - 使用 REST API 设置默认分支

git - 通过SSH创建Git存储库并在本地克隆

apache-spark - 如何在独立主机中并行运行多个Spark应用程序

C++ 全局配置类或所有应用程序可见的源代码?

Apache 虚拟主机包括

.net - 要忽略的 Git .Net 文件

git - git-fetch 会复制整个存储库吗?

Git:将特定提交移动到另一个分支

.net - 如何调试.NET 中的配置文件?

kubernetes - Kubectl 配置 View 给出空结果