Git config not working

I have used git and github on this computer I am currently using (Windows 10), many times before, but I had not used it for a couple months. When I tried to make a commit to a new repository yesterday, it prompted me to do the git config --global user.email, and when I enter that, I get this error:

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

I followed that path and found there is no SPB_Data folder there (including hidden files). Also I found that my .gitconfig file is located in C:/Users/cwolf. I don’t know if solving the problem is as simple as making a SPB_Data folder and putting that .gitconfig file in it, but I don’t want to try that if I don’t know what I’m doing.

My question is what do I need to do to get the git config working again, and why did this happen if everything used to be working a couple months ago, same computer, same operating system?

As you stated you are using Windows 10. It’s look like your .gitconfig is broken.
This is minimum .gitconfig in your home folder (In your case C:/Users/cwolf) If the .gitconfig is not in your home folder then rectify it.
This is the global config which is necessary. Try opening it and see do this file look like this.

[user]
	email = youremail@example.com
	name = Your sweet name
	signingkey = XX26XXXXXXXXXX87
[gpg]
	program = %PATH_OF_GPG
[commit]
	gpgsign = true

If still it doesn’t work, THEN
Try setting global config through command line by- git config --global user.email "MY_NAME@example.com" It automatically set the .gitconfig in the directory it needed.
You can follow Offical DOCS to set .gitconfig.

This MAY happen because you updated your git/system and something unexpected happen or any app misbehaved with your git.
IF you can then try a clean and updated git install. (Uninstall git and install it from offical website. Git)
If nothing happens then I can’t help.

This is what my .gitconfig file looks like, located in C:\Users\cwolf:

[user]
name = Charles
email = c.wolfe132@gmail.com
[core]
editor = ‘C:/Program Files (x86)/Notepad++/notepad++.exe’
autocrlf = true
excludesfile = C:\Users\cwolf\Documents\gitignore_global.txt
[filter “lfs”]
smudge = git-lfs smudge – %f
process = git-lfs filter-process
required = true
clean = git-lfs clean – %f

And the file in C:\ProgramData\Git just called “config” looks like this:

[core]
symlinks = false
autocrlf = true
fscache = true
[color]
diff = auto
status = auto
branch = auto
interactive = true
[help]
format = html
[rebase]
autosquash = true

I am going to try uninstalling and reinstalling Git now, and I hopefully that works

Did u try this. If .gitconfig file location changed then it will create it at required place.
Else Best of luck!

I just uninstalled Git and then reinstalled it, and tried a git config again, same error:

Maybe some environment variables have been changed on your system.
I would check the values of HOME , HOMEPATH and USERPROFILE .

see is there any changed then return those to default

Ok I just straight up made a new folder called SPB_Data and copy and pasted my .gitconfig file into it, and that worked.

Yup but just check the enviroment variable. The git is considering home as C:/ProgramData/SPB_Data/ but we both know it not.
Home is C:/Users/cwolf in your case.

USERPROFILE=C:\Users\cwolf
HOMEPATH=\Users\cwolf

but then

HOME=C:\ProgramData\SPB_Data

Ok just to make sure I don’t accidentally break something, what’s the best way to reset that one environment variable

Just edit it. This is the culprit.
May be you installed some app in recent day. And you given admin privilege and the app changed the path. Just change it and it will set everything good for any app that depend on home directory for config like git or node.

NOOB HINT- Keep a eye on slash (/ ‘’) both are different.

Thank you for your help. You guys are way more chill than the people on stack overflow

Did you tried changing the environment variable? Did it worked?

Mark this question as solved if satisfied. Or drop a like.

1 Like