Reputation: 181
While trying to set up Git with my GitHub account the following error keeps persisting whenever I try to do a global config.
It works fine for repositories, but the global doesn't work.
Here's how it shows:
$ git config --global user.name "username"
error: could not lock config file C:/Path/to/.gitconfig: File exists
I'm using Git 2.21.0 on Windows 10 Pro.
Upvotes: 18
Views: 64631
Reputation: 1
I got the error after I did reboot my machine with recent SW changes mandated by my organization! I just reboot my machine again and the error went away! Try to reboot your machine first to see if it fixes the error! Cheers! :)
Upvotes: -1
Reputation: 1
I have just had this issue and the "problem" was a security configuration in Windows, Folder lock or something like that. It is under Settings > Windows Security > Protection History. If you allow the access, it should work just fine
Upvotes: 0
Reputation: 39
In other situation, If you don't have .gitconfig.lock
file, there should be a config.lock
file in .git
folder of the repo.
You can delete this file and It will fixed this problem.
Upvotes: 2
Reputation: 141
Since you're on Windows 10, it could be an issue if your .gitconfig is located at C:. If that's the case, try running your git bash with Administrator privileges (right-click on your executable, select More > run as Administrator) and see if that works. You need administrator privileges to work on files at the root of C:. That worked for me.
Upvotes: 11
Reputation: 290
Check your folder where the .gitconfig
file is located, and if there is a .gitconfig.lock
file, delete it. I got the same error and this fixed it for me.
Upvotes: 12