Ask Ubuntu is a question and answer site for Ubuntu users and developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm getting this error when trying to set the global config:

$ git config --global "Your Name Here"
error: could not lock config file /pathto/file/.gitconfig: No such file or directory

and the file .gitconfig is already exists, anyone have any ideas??

share|improve this question
Do you have read/write permission on that file? (Check using ls -la /path/to/file/.gitconfig) – Salem Feb 19 '13 at 17:13
-rw-rw-r-- 1 .gitconfig – codepros Feb 19 '13 at 17:15
Are you running as the correct user? Which user owns .gitconfig? – Flimm Feb 19 '13 at 17:51
up vote 8 down vote accepted

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
    name = my_username
    email =
    editor = editor
    pager = most
    ui = auto
    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.

share|improve this answer
there is no file named .gitconfig.lock in home directory and .gitconfig is already exists ~/ – codepros Feb 19 '13 at 17:40
and where is .gitconfig? In ~/.gitconfig? If that's the case then try editing it by hand. – Salem Feb 19 '13 at 17:43
@Salem, I have the .gitconfig in the ~/ but still the error is there. Any advice? – uDaY Jan 3 '14 at 3:22

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

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

That's what worked for me.

share|improve this answer

My problem was similar to yours. I found that the "git" user was unable to access its home directory.

I did chown -R git:git /mnt/sdb1/git and this solved the permission error.

share|improve this answer

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

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.