当使用git config——global来设置时,它会写入哪个文件?
例子:
git config --global core.editor "blah"
我在这些地方都找不到:
C:\Program Files\Git\etc\gitconfig
C:\myapp\.git\config
我没有设置ENV?
我的Git版本:1.6.5.1.1367。gcd48 - 在Windows 7上
当使用git config——global来设置时,它会写入哪个文件?
例子:
git config --global core.editor "blah"
我在这些地方都找不到:
C:\Program Files\Git\etc\gitconfig
C:\myapp\.git\config
我没有设置ENV?
我的Git版本:1.6.5.1.1367。gcd48 - 在Windows 7上
当前回答
msysgit的路径如下:
Windows XP -C:\Documents and Settings\<user_name>\.gitconfig
Windows Vista+ C:\用户\<用户名>\.gitconfig
其他回答
.gitconfig文件位置
macOS测试OK
全球
# global config
$ cd ~/.gitconfig
# view global config
$ git config --global -l
当地的
# local config
$ cd .git/config
# view local config
$ git config -l
也许对你有好处:Vim或VSCode编辑git配置
# open config with Vim
# global config
$ vim ~/.gitconfig
# local config
$ vim .git/config
# open config with VSCode
# global config
$ code ~/.gitconfig
# local config
$ code .git/config
我正在运行Windows 7,并按照GitHub上的说明(一两年前)使用git作为安装。我认为这是一个相当常见的用例。上面的答案对我没有帮助,在经历了很多挫折后,我最终在以下目录中找到了我的“真正的”gitconfig文件;
C:\Users\Bill\AppData\Local\GitHub\PortableGit_054f2e797ebafd44a30203088cd 3D58663C627EF\etc
显然要替换用户名,PortableGit_后面的后缀是唯一的GUID或类似的。
在*nixes上,它在~/.gitconfig中。你家里有相应的文件吗?
在Windows上,你可以输入git bash
notepad ~/.gitconfig
只是完全同意@cameron-mckenzie在本页上的回答,上面关于何时创建全局的.gitconfig文件?(这显然适用于所有操作系统)。他的其余回答涉及Win7系统。
在Win10系统中也是如此,只有当你想要设置user.name & user时,才会第一次创建.gitconfig全局文件。通过Windows命令提示符电子邮件系统变量。设置完成后,.gitconfig文件将在%USERPROFILE% dir中创建。
下面的命令适用于Win和MacOS
因此,让我们假设.gitconfig文件已经存在。你可以通过Command-prompt/ git - bash/Terminal知道它的位置:
git config --global --list --show-origin
正如@MatrixFrog在他们的评论中指出的,如果目标是编辑配置,你可能想要运行:
git config --global --edit
这个命令将在选择的编辑器中打开配置文件(在本例中是——global文件),并等待文件关闭(就像git rebase -i期间一样)。