Git 警告:无法访问“P:\/.gitconfig”:参数无效

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/14774159/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-10 15:28:19  来源:igfitidea点击:

Git warning: unable to access 'P:\/.gitconfig': Invalid argument

gitgit-config

提问by Chris G.

I am just testing git. I ran the following command:

我只是在测试 git。我运行了以下命令:

git config user.email "[email protected]"

I now get this when git statusand others:

我现在得到这个时间git status和其他人:

C:\gitg\g1>git status
warning: unable to access 'P:\/.gitconfig': Invalid argument
warning: unable to access 'P:\/.gitconfig': Invalid argument
warning: unable to access 'P:\/.gitconfig': Invalid argument
# On branch master
warning: unable to access 'P:\/.gitconfig': Invalid argument
nothing to commit, working directory clean

C:\gitg\g1>

回答by Daniel Hilgarth

I just encountered this error.
Executing set HOMEPATHin the command line gave this output:

我刚刚遇到了这个错误。在命令行中
执行set HOMEPATH给出了这个输出:

HOMEPATH=\

Simply deleting this environment variable via set HOMEPATH=fixed the problem.

只需通过set HOMEPATH=修复问题删除此环境变量即可。

回答by JK Dennis

I experienced a similar issue when not connected to my work network via VPN. Deleting the all the HOME% variables did not work. Deleting the network drive it was trying to access did work. Running the following from a command window worked for me:

未通过 VPN 连接到我的工作网络时,我遇到了类似的问题。删除所有 HOME% 变量不起作用。删除它试图访问的网络驱动器确实有效。从命令窗口运行以下对我有用:

net use H: /delete

净使用 H: /delete

As a note, I did delete the HOME% variables, but it did work until the command above was run.

请注意,我确实删除了 HOME% 变量,但在运行上述命令之前它确实有效。

回答by David Victor

I hit on this and had to set HOMEDRIVE to something sane.

我找到了这个,不得不将 HOMEDRIVE 设置为理智的东西。

e.g.

例如

set HOMEDRIVE=D:

回答by kashiraja

If you are using "Git Bash" (MINGW64) on Windows:

如果您在 Windows 上使用“Git Bash”(MINGW64):

Enter:

进入:

export HOME=/c

To verify:

验证:

echo $HOME

回答by Naren

I was facing this issue when loading a solution in Visual Studio 2017 (v15.1) running as an Administrator. And my local git repo was located in C:\Code\

在以管理员身份运行的 Visual Studio 2017 (v15.1) 中加载解决方案时,我遇到了这个问题。我的本地 git repo 位于 C:\Code\

To work around the problem,

为了解决这个问题,

  1. I added an Environment Variable (under User variable) HOME with value C:\
  2. Restarted Visual Studio (again as an admin) - this time Git was able to load successfully loading my branch & source control association correctly.
  1. 我添加了一个环境变量(在用户变量下)HOME,值为 C:\
  2. 重新启动 Visual Studio(再次以管理员身份) - 这次 Git 能够成功加载正确加载我的分支和源代码控制关联。

回答by Shavelieva

Try running as Administrator. For whatever reason it defaults to a mapped drive.

尝试以管理员身份运行。无论出于何种原因,它默认为映射驱动器。

回答by Tobias Oberrauch

It works for me to clear the HOME Variable "nearly" to Daniels solution:

对我来说,将 HOME 变量“几乎”清除到 Daniels 解决方案对我有用:

set HOME=

To recheck you have to echo it like this:

要重新检查,您必须像这样回显:

echo %HOME%

回答by Hasson

For me, I have seen this error in sourcetree, it was just a matter of disconnecting the drive P in my computer as it was a net drive.

对我来说,我在 sourcetree 中看到过这个错误,这只是断开计算机中的驱动器 P 的问题,因为它是一个网络驱动器。

回答by Steve T

I experienced this error message intermittently.

我间歇性地遇到此错误消息。

The cause was a VPN connection that I used occasionally. It was blocking access to my networked HOMEDRIVE every time I used it; and git could no longer access the config file.

原因是我偶尔使用的 VPN 连接。每次使用它时,它都会阻止访问我的联网 HOMEDRIVE;并且 git 无法再访问配置文件。

Clearly not the cause here because you found your solution, but I thought I'd add it here for anyone else searching.

显然不是这里的原因,因为你找到了你的解决方案,但我想我会在这里添加它供其他人搜索。

回答by Hiren

Thanks @daniel-hilgrath, your answer helped me till an extent, it did solve for that particular session.

谢谢@daniel-hilgrath,你的回答在某种程度上帮助了我,它确实解决了那个特定的会话。

But in my case I was using SourceTree and on Windows 7. I had to wipe out the Environment variables completely, not only for particular session. I did following.

但就我而言,我使用的是 SourceTree 和 Windows 7。我必须完全清除环境变量,而不仅仅是针对特定会话。我做了以下。

SETX HOMEPATH ""
SETX HOMEDRIVE ""

may be this could be useful for someone who is using this on SourceTree.

这可能对在 SourceTree 上使用它的人有用。