When deleting remote git branch “error: unable to push to unqualified destination”

后端 未结 9 1892
南旧
南旧 2020-12-12 10:42

I\'m trying to delete a remote git branch with

git push origin :my_remote_branch

and getting:

error: unable to push to unq         


        
相关标签:
9条回答
  • 2020-12-12 11:10

    Found question cleaning up old remote git branches and this did the trick

    git branch -r -d origin/my_remote_branch
    
    0 讨论(0)
  • 2020-12-12 11:12
    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
    
    0 讨论(0)
  • 2020-12-12 11:12

    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.

    0 讨论(0)
  • 2020-12-12 11:14

    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>
    
    0 讨论(0)
  • 2020-12-12 11:15

    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.

    0 讨论(0)
  • 2020-12-12 11:24

    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
    
    0 讨论(0)
提交回复
热议问题