How do I delete a Git branch locally and remotely?

后端 未结 30 3738
被撕碎了的回忆
被撕碎了的回忆 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 04:59

    A one-liner command to delete both local, and remote:

    D=branch-name; git branch -D $D; git push origin :$D
    

    Or add the alias below to your ~/.gitconfig. Usage: git kill branch-name

    [alias]
        kill = "!f(){ git branch -D \"$1\";  git push origin --delete \"$1\"; };f"
    

提交回复
热议问题