使用git删除不在本地存储库中的分支
问题描述:
当我在GitHub上分支时,我的git repo中有一堆分支。我不希望我的GitHub fork有这些分支。使用git删除不在本地存储库中的分支
是否有任何方法可以删除我的GitHub仓库中不在本地仓库中的所有分支?
答
git push --mirror <origin>
将使远程的引用匹配本地存储库中的引用,包括删除本地没有的分支。
从git help push
:
--mirror Instead of naming each ref to push, specifies that all refs under refs/ (which includes but is not limited to refs/heads/, refs/remotes/, and refs/tags/) be mirrored to the remote repository. Newly created local refs will be pushed to the remote end, locally updated refs will be force updated on the remote end, and deleted refs will be removed from the remote end. This is the default if the configuration option remote.<remote>.mirror is set.
答
您可以删除远程分支机构我推空分支:
$ git push origin :branch-to-delete
因为有超过5家分行......我觉得这种方式是低效的是为什么我要寻找其他选择。 – xenoterracide 2010-08-21 06:35:45