I\'m trying to delete a remote git branch with
git push origin :my_remote_branch
and getting:
error: unable to push to unq
Found question cleaning up old remote git branches and this did the trick
git branch -r -d origin/my_remote_branch
git branch -r -d origin/my_remote_branch
was not enough for me. Before I had to go to server and work with git directory directly (which is dangerous and ugly) to remove the branch:
ssh mygitserver
su - git
cd /home/git/repositories/my_remote_branch.git/
git --git-dir=. --work-tree=/tmp/ branch -D my_remote_branch
I have the similar problem. First went to this discussion, however I couldn't solve the problem until I saw https://stackoverflow.com/a/32147743/4209849.
which simply add a tip on distinguishing origin/my-branch-name
and my-branch-name
.
To be specific, I should use:
git push origin :my_remote_branch
instead of
git push origin :origin/my_remote_branch
This solved my problem at least, hope it would help others as well.
Try following two options to delete remote branch forcibly
Option 1
get push origin --delete <branchName>
Option 2
git fetch -p origin
git branch -r -d origin/<branchName>
This worked for me: I created the remote branch on github UI and then pushed my local branch which had the same name to it. Try it in case other ways dont work. Other way would be creating a new branch locally and pushing an empty branch and later cherry-pick your commit and push again to your remote.
I ran across this when trying to delete a remote branch that had already been deleted. All that was needed was a prune:
git remote prune origin