How do I delete a Git branch locally and remotely?

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

    Tip: When you delete branches using

    git branch -d  # Deletes local branch
    

    or

    git push origin : # Deletes remote branch
    

    only the references are deleted. Even though the branch is actually removed on the remote, the references to it still exists in the local repositories of your team members. This means that for other team members the deleted branches are still visible when they do a git branch -a.

    To solve this, your team members can prune the deleted branches with

    git remote prune 
    

    This is typically git remote prune origin.

提交回复
热议问题