删除由git branch -a列出的分支 [英] Delete branches listed by git branch -a

查看:267
本文介绍了删除由git branch -a列出的分支的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

命令 git branch -a 列出了一些不在存储库中的分支,而不是本地分支。这些如何被删除?

  * develop 
master
遥控器/原点/克隆器

例如,回购中存在 remotes / origin / cloner ,但它具有自从被删除后,我希望它在输入 git branch -a 时不会出现。如果您有远程追踪分支(例如 origin / cloner >在这种情况下),在远程存储库中删除相应的分支之后剩下的,您可以删除所有这样的远程跟踪分支:

 
git remote prune origin

git remote 的文档解释为:


删除< name>下的所有陈旧的远程跟踪分支。这些陈旧的分支已经从< name>引用的远程存储库中移除,但仍然可以在远程/<名称>中本地获得。

code> - 干运行选项,报告将修剪哪些分支,但不会实际修剪它们。



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
  master
  remotes/origin/cloner

For example, remotes/origin/cloner used to exist in the repo, but it has since been deleted and I'd like it not to appear when typing git branch -a.

解决方案

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 <name>. These stale branches have already been removed from the remote repository referenced by <name>, but are still locally available in "remotes/<name>".

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

这篇关于删除由git branch -a列出的分支的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆