1

I'm trying to set git config values but I keep getting could not lock config file error whenever I try to update them. I've looked around on Stack Overflow and followed the advice to try and remove .gitconfig so that I can recreate it. However, I then get the error No such file or directory.

Does anyone know why this might be happening?

MacBook-Pro-10:~ Chris$ git config --global user.name "Chris Marshall"
error: could not lock config file /Users/Chris/.gitconfig: File exists

MacBook-Pro-10:~ Chris$ rm ~/.gitconfig
rm: /Users/Chris/.gitconfig: No such file or directory
  • Check the permissions on your home directory, but even with those being weird, you should not get this particular set of errors. Check to see if `~/.gitconfig.lock` exists as well: that might explain the problem. Git should be complaining about that path, but there's some squirrelly code here. – torek Jan 05 '20 at 10:56
  • That's worked thank you! It was the `~/.gitconfig.lock` that was causing the error. – Chris Marshall Jan 05 '20 at 11:16
  • Does this answer your question? [How to fix Git for Windows error: "could not lock config file C:/file/path/to/.gitconfig: File exists"?](https://stackoverflow.com/questions/55327408/how-to-fix-git-for-windows-error-could-not-lock-config-file-c-file-path-to-g) – phd Jan 05 '20 at 12:38
  • https://stackoverflow.com/search?q=%5Bgit%5D+%22error%3A+could+not+lock+config+file%22+%22.gitconfig%22+%22File+exists%22 – phd Jan 05 '20 at 12:38

0 Answers0