The full error is:
remote: error: cannot lock ref 'refs/heads/fix/add_overlay': reference already exists
I'm using SourceTree, but that should not matter I don't think. I keep trying to push and I keep getting this error, how can I resolve it?
TL;DR: try removing their branch fix
, i.e., their refs/heads/fix
, which I suspect is in the way. (Be sure they don't care if you remove it!)
The error message is very odd. If the reference refs/heads/fix/add_overlay
exists, that's not a problem! Git should be able to lock it, and if it can't, the reason it can't is not "because it exists".
I suspect that this may be a misleading error message: it may be that the reference refs/heads/fix
—not refs/heads/fix/add_overlay
—exists, so it's impossible to create a directory refs/heads/fix/
in which to hold the sub-reference refs/heads/fix/add_overlay
because the existing reference refs/heads/fix
is in the way.
You can tell whether this is the case by examining the set of references that exist (by using git ls-remote
, or after a git fetch -p
, by looking at your own set of remote-tracking names that are based on their branch names). And, if it is the case, you should convince them—whoever they are—to rename or remove their branch fix
so that you can have them create a directory named fix/
containing branch names like fix/add_overlay
.
Fix
in uppercase in your comment here. Is it possible there is a case sensitive fix
vs Fix
and some sort of case folding issue on the server?
This error can occur when attempting to push to a folder with the same name as an existing branch.
To remove that error, navigate to your project directory and run git remote
and then remove the origin by running git remote rm origin
.Create a new repository,
[assuming you use GitHub] by running git remote add origin https://github.com/your_user_name/your_repository_name.git
, and push the changes to the remote server,git push -u origin master
.This should work.