繁体   English   中英

如何删除本地不存在的分支机构

[英]How could I remove local unexisting branches

这些分支不再存在于远程原始服务器上,

但是我无法删除

gb -D origin/feature/support-auto-backupgb -D remotes/origin/feature/add-discussion

我遇到了这种异常error: branch 'origin/feature/support-auto-backup' not found.

如何删除所有这些?

在我的本地工作空间上分支

  remotes/origin/feature/add-discussion
  remotes/origin/feature/add-ios-push-notification
  remotes/origin/feature/add-monitor-and-upstart-service
  remotes/origin/feature/add-ng-highcharts
  remotes/origin/feature/add-paypal-support
  remotes/origin/feature/move-status-watch-to-admin
  remotes/origin/feature/periodic_prices_rake_task
  remotes/origin/feature/personal-watch-list
  remotes/origin/feature/refactor_to_new_model
  remotes/origin/feature/structure_refactor
  remotes/origin/feature/support-auto-backup
  remotes/origin/feature/support-currency-conversion
  remotes/origin/feature/support_add_other_emails

git fetch --prune使用git fetch --prunegit fetch -p 这将从远程获取分支的更新列表,并更新您的远程分支集以反映这一点。 如果您有不再存在的远程分支,则将删除那些分支。

手册说明了此选项:

-p
--prune

提取后,删除远程上不再存在的所有远程跟踪引用。 如果仅由于默认标签自动跟随或--tags选项而获取标签,则不对它们进行修剪。 但是,如果由于显式的refspec (在命令行或在远程配置中,例如,如果使用--mirror选项克隆了远程--mirror )而获取了--mirror ,则也将对其进行修剪。


如果要从本地存储库中手动删除远程分支,则不能仅使用git branch -dgit branch -D 默认情况下,它仅使您可以访问本地分支机构,而不能访问远程分支机构。 但是,可以使用--remote-r选项删除分支。 请注意,您仅可以指定远程分支名称,而不能指定前导remotes/ ,例如:

git branch -d -r origin/feature/add-discussion

git branch手册中也解释了此功能:

-r-d一起使用可删除远程跟踪分支。 请注意,仅当远程跟踪分支不再存在于远程存储库中或git fetch配置为不再再次获取它们时,才有意义。 另请参阅git-remote [1]的prune子命令,以清除所有过时的远程跟踪分支。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM