Deleting a remote branch

后端 未结 4 1858
慢半拍i
慢半拍i 2020-12-18 06:04

When I perform branch -a:

$ git branch -a
* master
 remotes/origin/HEAD -> origin/master
 remotes/origin/hello
 remotes/origin/master
         


        
4条回答
  •  余生分开走
    2020-12-18 06:47

    To delete a remote branch, use

    git push origin :remotebranch
    

    Everything else operates on the local repository only. In more recent versions of git, you can also

    git push origin --delete remotebranch
    

    As per the documentation, --delete means the same "as prefixing all refs with a colon".

    If you are wondering about meaning of the :, it follows the standard syntax for push. Usually, you would write

    git push origin localbranch:remotebranch
    

    but here, you replace localbranch with "nothing", effectively deleting the remote branch.

提交回复
热议问题