I\'m getting this error when trying to set the global config:
$ git config --global user.name \"Your Name Here\"
error: could not lock config file /pathto/fi
In Windows: Right click on "Git Bash" icon -> Run as Administrator. it helped me.
Git tries to create a config file on disk C:/ but it has no permission to do that.
I started getting this error after windows upgrade. My Home variable somehow removed after windows upgrade. Issue resolved by adding HOME variable as "C"\Users\myusername".
A bit like in "Trouble setting up Tower with my GitHub Account - error: could not lock config file", check how that ~/.gitconfig
file has been created.
Ie: with which rights associated to it?
Make also sure your $HOME
variable is correctly set when you are executing the git config --global
command.
Just use the following command if you wanna set configuration in system level:
$ sudo git config --system user.name "my_name"
In my case, the .git/config
file was created not in my $HOME
directory, but inside my repository on .git/config.lock
Deleting the file fixed the problem. The file is created, when I switch branches with git checkout -f branchname
and files from a recently created submodule were overwritten by git checkout.
$ git branch --set-upstream-to=origin/branchname
error: could not lock config file .git/config: File exists
error: Unable to write upstream branch configuration
hint:
hint: After fixing the error cause you may try to fix up
hint: the remote tracking information by invoking
hint: "git branch --set-upstream-to=origin/branchname".
This could be caused by the presence of ~/.gitconfig.lock It's possible this file could be an artifact of a previously running git that was aborted for some reason, e.g. ansible timed out or ^C