当使用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上
当前回答
我还在我的Windows机器上寻找全局的.gitconfig,并用git找到了这个巧妙的技巧。
执行a: gitconfig——global -e,然后,如果你幸运的话,你会得到一个文本编辑器加载你的全局.gitconfig文件。只需从那里查找文件夹(或尝试另存为…),等voilà!: -)
其他回答
我把Git安装在:C:\Users\_myuserfolder_\AppData\Local\Programs\Git
在*nixes上,它在~/.gitconfig中。你家里有相应的文件吗?
在Windows上,你可以输入git bash
notepad ~/.gitconfig
我在Windows 8.1上使用SmartGit和msysgit,并注意到gitconfig文件可以有三个不同的位置:
%USERPROFILE%\.gitconfig
C:\Program Files (x86)\Git\etc\gitconfig
C:\Program Files (x86)\SmartGitHg\git\etc\gitconfig
但是使用的是来自%USERPROFILE%\.gitconfig的。
我认为这句话很重要:
Git for Windows supports four levels of configuration. At the lowest level is the machine specific configuration settings known as "portable" and lives a "%ProgramData%\Git\config". One priority level us the installation specific configuration settings known as "system", which live at "\mingw64\etc\gitconfig". Both of these configuration file, generally require elevated privileges to modify. Starting with the use specific values known as "global" configuration, which can be found at "%UserProfile%.gitconfig", we find the "user editable" configuration files. The highest priority configuration settings are in the "local" configuration, which can usually be found at ".git\config". It see the recommendation in the blog linked is to modify the "system" or "installation" specific configuration settings, which is fine but users should expect that other installations of Git would not absorb said settings. If you want machine wide settings, use the "portable" configuration file, otherwise choose the "global" or "local" configuration files. Hopefully, people find this information useful.
源
.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