清理远程 Git 分支
我已经将 SVN 存储库移至 Git,可能由于多次克隆,我现在留下了一堆看起来像
BranchA
origin/BranchA
remotes/BranchA
remotes/origin/BranchA
remotes/origin/origin/BranchA
同一分支被列出多次的分支。我该如何清理这个烂摊子。有> 50 个分支,有些根本不需要,其余的我只要拥有一次就很高兴了。
编辑:
show origin 在某种情况下的样子:
Remote branches:
BranchA tracked
origin/BranchA tracked
......
Local branches configured for 'git pull':
origin/BranchA merges with remote BranchA
这就是 git Remote
Local refs configured for 'git push':
BranchA pushes to BranchA (up to date)
origin/BranchA pushes to origin/BranchA (up to date)
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)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以使用以下命令删除这些分支:
要删除
BranchA
分支:要删除
origin/BranchA
分支:或者,您可以使用
gitbranch -dr BranchA等等。
删除除
BranchA
和origin/BranchA
之外的所有分支。您可能已删除origin
遥控器,在这种情况下,您应该删除remotes
遥控器并将其重新添加为origin
遥控器。You can remove these branches by using this command:
To remove the
BranchA
branch:To remove the
origin/BranchA
branch:Alternatively you could use
git branch -dr BranchA
and so on.Remove every branch except
BranchA
andorigin/BranchA
. You may have deleted theorigin
remote, in which case you should remove theremotes
remote and re-add it as theorigin
remote.