清理远程Git分支 [英] Cleaning remote Git branches
问题描述
我将一个SVN仓库转移到了Git仓库,可能是由于一些clonings,我现在留下了一堆看起来像
BranchA
原产地/ BranchA
遥控器/ BranchA
遥控器/原产地/ BranchA
遥控器/原产地/原产地/ BranchA
即同一分支列出了多次。我怎样才能清理这个烂摊子。有> 50个分支,有些根本不需要,剩下的我只会让他们有一次感到高兴。
编辑:
这就是git remote show origin在某些情况下的样子:
远程分支:
已追踪的分行A $ b $原产地/已追踪的分行
...
为'git pull'配置的本地分支:
origin / BranchA与远程BranchA合并
...
本地参考配置'git push':
BranchA推送到BranchA(最新)
origin / BranchA推送到origin / BranchA(最新)
您可以使用以下命令删除这些分支:
git push origin:branch_name
删除 BranchA
分支:
git push origin:BranchA
删除 origin / BranchA
分支:
git push origin:origin / BranchA
另外你可以使用 git branch -dr BranchA
等等。
删除除 BranchA
和 origin / BranchA
。您可能已经删除了 origin
remote,在这种情况下,您应该删除 remotes
remote并重新添加它为来源
远程。
I have moved an SVN repo to Git and probably due to a number of clonings, I'm now left with a bunch of branches that look like
BranchA
origin/BranchA
remotes/BranchA
remotes/origin/BranchA
remotes/origin/origin/BranchA
i.e. the same branch is listed a number of times. How can I clean this mess up. There are > 50 branches, some are not needed at all, and for the rest I'd be happy with just having them once.
EDIT:
This is what git remote show origin looks like for a certain case:
Remote branches:
BranchA tracked
origin/BranchA tracked
...
Local branches configured for 'git pull':
origin/BranchA merges with remote BranchA
...
Local refs configured for 'git push':
BranchA pushes to BranchA (up to date)
origin/BranchA pushes to origin/BranchA (up to date)
You can remove these branches by using this command:
git push origin :branch_name
To remove the BranchA
branch:
git push origin :BranchA
To remove the origin/BranchA
branch:
git push origin :origin/BranchA
Alternatively you could use git branch -dr BranchA
and so on.
Remove every branch except BranchA
and origin/BranchA
. You may have deleted the origin
remote, in which case you should remove the remotes
remote and re-add it as the origin
remote.
这篇关于清理远程Git分支的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!