Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to fix Git for Windows error: "could not lock config file C:/file/path/to/.gitconfig: File exists"?

Tags:

git

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.

like image 930
tatzooism Avatar asked Mar 24 '19 19:03

tatzooism


People also ask

How do I open a git config file in Windows?

gitconfig located in the user's home folder (C:\Users\git user) Local Git configuration: File named config in the . git folder of the local repo.

Why git config is not working?

Try opening it and see do this file look like this. Try setting global config through command line by- git config --global user. email "[email protected]" It automatically set the . gitconfig in the directory it needed.


1 Answers

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.

like image 69
rup Avatar answered Sep 17 '22 16:09

rup