在Windows上更改.gitconfig位置 [英] Changing .gitconfig location on Windows
问题描述
默认情况下,Windows Git将全局.gitconfig放置在 c:\文档和设置中\用户\
By default on Windows Git places global .gitconfig in c:\documents and settings\user\
如何更改该位置,以便.gitconfig存储在 c:\ my_configuration_files \
?
How can I change that position so .gitconfig is stored in c:\my_configuration_files\
?
完全可以做到这一点吗?
Can it be done at all?
推荐答案
如果您设置 HOME
到 c:\my_configuration_files\
,那么git会在那里找到.gitconfig。编辑环境变量在此处描述。您需要设置HOME变量,然后重新打开任何cmd.exe窗口。使用set命令来验证HOME确实指向了正确的值。
If you set HOME
to c:\my_configuration_files\
, then git will locate .gitconfig there. Editing environment variables is described here. You need to set the HOME variable, then re-open any cmd.exe window. Use the "set" command to verify that HOME indeed points to the right value.
当然,更改HOME也会影响其他应用程序。但是,通过阅读git的源代码,这似乎是更改这些文件位置的唯一方法,无需调整命令行。你还应该考虑Stefan的回应:你可以设置GIT_CONFIG变量。然而,为了达到你想要的效果,你需要将 - global
标志传递给所有的git调用(加上任何本地的.git / config文件都被忽略)。
Changing HOME will, of course, also affect other applications. However, from reading git's source code, that appears to be the only way to change the location of these files without the need to adjust the command line. You should also consider Stefan's response: you can set the GIT_CONFIG variable. However, to give it the effect you desire, you need to pass the --global
flag to all git invocations (plus any local .git/config files are ignored).
这篇关于在Windows上更改.gitconfig位置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!