全局 git 配置数据存储在哪里? [英] Where is the global git config data stored?

查看:37
本文介绍了全局 git 配置数据存储在哪里?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当使用 git config --global 进行设置时,它会写入哪个文件?

When using git config --global to set things up, to which file will it write?

示例:

git config --global core.editor "blah"

我在这些地方找不到它:

I can't find it at these places:

C:Program FilesGitetcgitconfig

C:myapp.gitconfig

我还没有设置 ENV?

I have not set an ENV?

我的 Git 版本:1.6.5.1.1367.gcd48 –在 Windows 7 上

My Git version: 1.6.5.1.1367.gcd48 – on Windows 7

推荐答案

Update 2016: with git 2.8 (March 2016), you can simple use:

Update 2016: with git 2.8 (March 2016), you can simply use:

git config --list --show-origin

在 Git 2.26(2020 年第一季度)中,您可以添加 --show-scope 选项

And with Git 2.26 (Q1 2020), you can add a --show-scope option

git config --list --show-origin --show-scope

你会看到哪个配置设置在哪里.
请参阅我的 Git 配置中的设置从何而来?"

You will see which config is set where.
See "Where do the settings in my Git configuration come from?"

正如 Stevoisiak 指出的那样 在评论中

As Stevoisiak points out in the comments,

它将适用于非标准安装位置.(即 Git Portable)

it will work with non-standard install locations. (i.e. Git Portable)

(就像最新的 PortableGit-2.14.2-64-bit.7z.exe,可以解压到任意位置)

(like the latest PortableGit-2.14.2-64-bit.7z.exe, which can be uncompressed anywhere you want)

原始答案 (2010)

Original answer (2010)

来自文档:

对于写入选项:写入全局 ~/.gitconfig 文件而不是存储库 .git/config.

--global

For writing options: write to global ~/.gitconfig file rather than the repository .git/config.

由于您使用的是 Windows 版 Git,因此可能不清楚这对应于哪个位置.但是如果你查看 etc/profile(在 C:Program FilesGit 中),你会看到:

Since you're using Git for Windows, it may not be clear what location this corresponds to. But if you look at etc/profile (in C:Program FilesGit), you'll see:

HOME="$HOMEDRIVE$HOMEPATH"

含义:

C:UsersMyLogin

(在 Windows 7 上)

(on Windows 7)

这意味着该文件位于 C:UsersMyLogin.gitconfig 中,用于 Windows 7 中的 Git.

That means the file is in C:UsersMyLogin.gitconfig for Git in Windows 7.

这篇关于全局 git 配置数据存储在哪里?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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