Trouble setting up git error: could not lock config file

See if any of those tips help you:

  1. Verify if there's some file called ~/.gitconfig.lock. If that's the case just delete it.

  2. The file ~/.gitconfig belongs to you (use ls -la ~/.gitconfig to check). If it does not you can change the ownership using sudo chown <your_username>:<your_username> ~/.gitconfig

If none of these solves the problem you can always edit ~/.gitconfig using your favorite text editor. It is just a INI like file. An example:

$ cat ~/.gitconfig
[user]
    name = my_username
    email = [email protected]
[core]
    editor = editor
    pager = most
[color]
    ui = auto
[merge]
    conflictstyle = diff3

I am assuming the correct location is ~/.gitconfig. If that's not the case replace it with the correct path.

Hope it helps.


In my case, there is a file .git/config.lock file in my git repo. I deleted that file and it solved the problem.


You need to own the directory where .gitconfig is in:

chown -R <user>.<user> /pathto/file/

That's what worked for me.

Tags:

Git

12.10