fatal: unable to access 'H:\/.config/git/config': Invalid argument [Git on Windows 7]

这一生的挚爱 提交于 2019-12-20 11:10:57

问题


I get this error when opening a git repository:

fatal: unable to access 'H:/.config/git/config': Invalid argument

Where in git is this path being pulled from?

'H:/.config/git/config'

I found some articles that it might be the "Home" or "UserProfile" environment variables but in my case the "Home" variable is not created and the "UserProfile" is not pointing to that path. So where is git getting that path from?


回答1:


I experienced a similar issue when not connected to my work network via VPN. Running the following from a command window worked for me:

net use H: /delete

This command actually deleted the H drive. If you actually use the mapped drive that is causing the issue, then this way could cause you other problems that would only be solved by remapping the drive (net use H:, followed by the mapped drive path). As a note, I did delete the HOME% variables (using "set HOME=" from the command line), but it did work until the command above was run.




回答2:


net delete is not a must.

First check HOME setting, then change HOME and HOMEDRIVE to a existing dir.

c:\git\selenium-automation>set HOME
HOME=U:\
HOMEDRIVE=U:
HOMEPATH=\
HOMESHARE=\\XX

then change HOME and HOMEDRIVE by

set HOME=c:\tmp
set HOMEDRIVE=C:

c:\git\selenium-automation>set HOME

HOME=c:\tmp
HOMEDRIVE=c:
HOMEPATH=\
HOMESHARE=\\XX



回答3:


Make sure, in a command line window:

  • HOME is indeed not set: type set HOME, which would return its value if any
  • the issue persists with the latest msysgit distribution (1.9.0): unzip that archive anywhere, and call git with its full path:

    c/mydir/PortableGit-1.9.0-preview20140217/bin/git.exe --global -l
    



回答4:


Set HOME var in 'User variable for ' (Control Panel\All Control Panel Items\System\ => Advanced system settings\Advanced\Env variables)

It resolved my issue.




回答5:


A lot of solutions were presented. Conclusion: The problem is a remote HOMEPATH and HOMEDRIVE environmental variable and appears when you are not connected to your network.

IMHO the solution with no side-effects (when your HOME variable is not set) is setting your HOME environmental variable of your profile to an existing local path.

First check if HOME is set or not. Open cmd.exe (Command prompt) and type

set HOME

If you do not get a result, just for HOMEPATH and HOMEDRIVE, than HOME is NOT set. Go to control panel:

Press WIN-R and then type control. Go to users profiles and you find a link on the left sidebar to change the environmental variable of your profile. The rest should be self-explanatory. Add variable HOME with path e.g. c:\users\myprofile.

With this attempt you could let HOMEPATH and HOMEDRIVE untouched and get no side-effects when reconnected to your network.

Worked for me.

IMPORTANT: But you lose your git settings. So you have to copy at least .gitconfig from your remote network home drive to your new local HOME directory before you disconnect from your network.

Thanks to Navjot Bhardwaj and VonC.




回答6:


If you'll check your GIT installation path /git/etc/profile you'll see HOME variable set as:
HOME="$HOMEDRIVE$HOMEPATH"

For this I created HOME variable in my Environment variables and it started working.




回答7:


As some people are saying this seems to be an issue with HomeDrive and HomePath when using network drives.

For me this was solved by running my git commands as admin.




回答8:


My situation was that I ran git checkout <branch> and I had fatal: unable to access 'H://.gitconfig': Invalid argument. Then I run set HOME and had no results. The following steps solved the issue

  1. change SSH keys
  2. restart the computer
  3. find .gitconfig (should be in the root of H:// or whatever drive name you have)
  4. open it with Notepad++ (or other editor) and save as is. If it is empty, then save empty one
  5. then git checkout master started working

If it happned once again, I would start from step 3 :-)



来源:https://stackoverflow.com/questions/22736191/fatal-unable-to-access-h-config-git-config-invalid-argument-git-on-windo

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!