Where does git config --global get written to?

2019-01-01 08:00发布

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 Files\Git\etc\gitconfig

C:\myapp\.git\config

I have not set an ENV?

My Git version: 1.6.5.1.1367.gcd48 – on Windows 7

标签: git config
15条回答
素衣白纱
2楼-- · 2019-01-01 08:05

On *nixes, it's in ~/.gitconfig. Is there a corresponding file in your home?

On Windows you can type in git bash

notepad ~/.gitconfig
查看更多
皆成旧梦
3楼-- · 2019-01-01 08:12

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.

查看更多
浪荡孟婆
4楼-- · 2019-01-01 08:12

If you are using TortoiseGit on a windows PC you can use:

Settings / Git / Config / Edit global .gitconfig

to open the global .gitignore file.

But if you use your Windows (7) PC in a domain your profile dir is may be a network share (mounted as a drive). In this case TortoiseGit (at least:1.6.5.0) is pointing you to the wrong dir (on c:...). See the closed TortoiseGit issue 922 for more information. Or using %HOMEDRIVE%%HOMEPATH% to open the dir that contains the .gitignore file.

查看更多
牵手、夕阳
5楼-- · 2019-01-01 08:12

It might be useful to note (for *nix platforms): some types of global git configuration/information are stored in /usr/share/git-core/, such as git autocompletion scripts and the following (default) hooks:

  • applypatch-msg
  • post-update
  • pre-commit
  • prepare-commit-msg
  • commit-msg
  • pre-applypatch
  • pre-rebase
  • update

Each of these can contain their own set of commands to execute, at the time described by their respective filenames.

查看更多
心情的温度
6楼-- · 2019-01-01 08:13

I had also a problem with my global .gitconfig This is for the case someone also has this strange

git said:

fatal: unknown error occured while reading the configuration files

Now I fixed it. The problem was a second .gitconfig in this folder:

c:\Users\myUser.config\git\config

I don't know where it came from... But now everything works like a charme again.

查看更多
ら面具成の殇う
7楼-- · 2019-01-01 08:14

The paths for msysgit are:

Windows XP -C:\Documents and Settings\<user_name>\.gitconfig

Windows Vista+ C:\Users\<user_name>\.gitconfig

查看更多
登录 后发表回答