Delete branches listed by git branch -a

前端 未结 4 736
Happy的楠姐
Happy的楠姐 2021-02-12 11:44

The command git branch -a lists a bunch of branches that are NOT on the repository, and NOT local branches. How can these be deleted?

* develop
  m         


        
4条回答
  •  花落未央
    2021-02-12 12:29

    If you have remote-tracking branches (such as origin/cloner in this case) which are left over after the corresponding branch has been deleted in the remote repository, you can delete all such remote-tracking branches with:

    git remote prune origin
    

    The documentation for git remote explains this as:

    Deletes all stale remote-tracking branches under . These stale branches have already been removed from the remote repository referenced by , but are still locally available in "remotes/".

    With --dry-run option, report what branches will be pruned, but do not actually prune them.

提交回复
热议问题