Where is the global git config data stored?
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 Files\Git
), you'll see:
HOME="$HOMEDRIVE$HOMEPATH"
Meaning:
C:\Users\MyLogin
(on Windows 7)
That means the file is in C:\Users\MyLogin\.gitconfig
for Git in Windows 7.
I was also looking for the global .gitconfig
on my Windows machine and found this neat trick using git.
Do a: git config --global -e
and then, if you are lucky, you will get a text editor loaded with your global .gitconfig
file. Simply lookup the folder from there (or try a save as...), et voilà! :-)
On *nixes, it's in ~/.gitconfig
. Is there a corresponding file in your home?
On Windows you can type in git bash
notepad ~/.gitconfig
The paths for msysgit are:
Windows XP -C:\Documents and Settings\<user_name>\.gitconfig
Windows Vista+ C:\Users\<user_name>\.gitconfig
The global location is derived, on Windows MsysGit, using the HOMEDRIVE and HOMEPATH environment variables, unless you have defined a HOME environment variable. The is detailed in the 'profile' script.
In my corporate environment the HOMEDRIVE is H:, which is then mapped to a network URL \\share\$. The whole lot is then mapped to be "My Documents", which isn't where others would expect. There may have been some further problems with the drive to URL remapping. I don't even get to adjust the HOMEDRIVE or HOMEPATH variables anyway.
In my case I have defined a personal HOME environment variable and pointed it to D:\git\GitHOME and copied all those GIT files (which are without and extension) to the GitHOME directory for safe keeping.
The windows environment variables can be set via the Advanced tab in the My Computer properties dialog.