在我的 Windows 10 机器上,当我运行时:
git config --global -l
Run Code Online (Sandbox Code Playgroud)
它失败并显示消息:
致命:无法读取配置文件“%HOMEDRIVE%%HOMEPATH%/.gitconfig”:没有这样的文件或目录
两个环境变量看起来都不错(对我来说),并且 .gitgconfig 是我认为应该在的位置:
C:\Users\BRITTG2>echo %homedrive%
P:
C:\Users\BRITTG2>echo %homepath%
\
C:\Users\BRITTG2>dir %homedrive%%homepath%.gitconfig
Volume in drive P is home
Volume Serial Number is 8076-09DA
Directory of P:\
03/25/2019 02:34 PM 658 .gitconfig
1 File(s) 658 bytes
0 Dir(s) 2,908,136,849,408 bytes free
Run Code Online (Sandbox Code Playgroud)
我缺少什么?
小智 7
以管理员身份运行 powershell(但您可以使用 cmd、Git bash 等)并重试。就我而言:
cd C:\ROstuff\ROprojects\Python\
git init
git config --global user.name "Rodrigo H Padilla"
git config --global user.email "Myemail@email.com"
git config --global -l
Run Code Online (Sandbox Code Playgroud)
找到一个旧帖子(我的!),其中包含解决方法:
git CMD 找到 .gitconfig 但 Windows cmd 找不到?
底线:Windows 上的 git 不使用 homedrive 和 homepath。它正在使用环境变量 home。当我设置它时,它起作用了