当我在GitHub上分叉时,我的git repo上有一堆分支。我不希望我的GitHub fork拥有这些分支。
有什么方法可以删除我的GitHub仓库中不在我本地仓库中的所有分支?
答案 0 :(得分:7)
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.
答案 1 :(得分:1)
你可以删除远程分支我推空分支:
$ git push origin :branch-to-delete