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

后端 未结 9 1016
慢半拍i
慢半拍i 2021-02-03 22:34

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?<

9条回答
  •  挽巷
    挽巷 (楼主)
    2021-02-03 23:34

    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.

提交回复
热议问题