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

Viewed 764

I just installed git on window 7. I dont know much about git that's why taking course from https://www.coursera.org/learn/introduction-git-github. After getting installed we configure our git user name and email by the following command:

$ git config --global user.name "your name"
$ git config --global user.email "your email"

but every time I get an error states that:

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

why isn't it working. I also watch some youtube videos and it works for other people very well.

2 Answers

Had a similar issue. Also couldn't use git clone. What appears to be an issue is a corrupted HOME environment variable. To fix this, set HOME environment variable for your user to C:\Users\<your_username>. This can be done using the PowerShell:

[Environment]::SetEnvironmentVariable("HOME", "C:\Users\<your_username>", "User")

or alternatively, you can use UI to set it. Instructions are HERE

After setting the environment variable you should be able to use git to its fullest. You would need to restart your terminal.

[EDIT] This was most likely caused by installing some of the Cadence software. Source.

Making the configurations locally for every repository you work on can be a workaround.

$ git config user.name "your name"
$ git config user.email "your email"
Related