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".