How do I delete a Git branch locally and remotely?

后端 未结 30 3583
被撕碎了的回忆
被撕碎了的回忆 2020-11-21 04:11

I want to delete a branch both locally and remotely.

Failed Attempts to Delete a Remote Branch

$ git branch -d         


        
30条回答
  •  野趣味
    野趣味 (楼主)
    2020-11-21 05:09

    I got sick of googling for this answer, so I took a similar approach to the answer that crizCraig posted earlier.

    I added the following to my Bash profile:

    function gitdelete(){
        git push origin --delete $1
        git branch -D $1
    }
    

    Then every time I'm done with a branch (merged into master, for example) I run the following in my terminal:

    gitdelete my-branch-name
    

    ...which then deletes my-branch-name from origin as as well as locally.

提交回复
热议问题