Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
281 views
in Technique[技术] by (71.8m points)

Where is the global git config data stored?

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

Example:

git config --global core.editor "blah"

I can't find it at these places:

C:Program FilesGitetcgitconfig

C:myapp.gitconfig

I have not set an ENV?

My Git version: 1.6.5.1.1367.gcd48 – on Windows 7

Question&Answers:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

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

git config --list --show-origin

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

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

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

As Stevoisiak points out in the comments,

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

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


Original answer (2010)

From the docs:

--global

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

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"

Meaning:

C:UsersMyLogin

(on Windows 7)

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


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...