1

I am getting an error message when I try to run the command git config --global user.name into bash. The error message reads:

error: could not lock config file C:/Projects/.gitconfig: No such file or directory

When I do echo $HOME, I get /c/projects

The folder C:/Projects doesn't even exist anymore so I have some idea about what may be going on here. The PATH of an older version of GIT to reach the home directory was c:/projects and some wires may be getting crossed. Right

Well now... if this is the issue I don't know how to change the path back to C:/users/anthonyd (where the current .gitconfig file is located along with .bashrc, .gitignore. etc.) and until I do I can't run any commands without issue.

Of course I could be wrong about what's causing the issue, but if there is someone that recognizes this issue, or has had this problem before I would appreciate help with a fix.

brunorey
  • 2,135
  • 1
  • 18
  • 26
Mainfram3
  • 11
  • 5
  • If there is a `.gitconfig.lock` in that path, then delete it. Check the owner of the `.gitconfig` file, if it's not you then give yourself the ownership of the file – Krishna Mar 12 '19 at 19:12

1 Answers1

3

You pointed out the root of the problem in the question. The problem is with your HOME configuration. Git is trying to open a file that doesn't exist, and the directory HOME is pointing to is non-existent too. Change the path of your HOME environment variable to your actual home directory.

export HOME=/c/users/anthonyd

You can also add that export command to your ~/.bash_profile.

Then, force the creation of the global configuration file with git config --edit --global. This will give you the .gitconfig for editing global configurations in your new HOME directory.