繁体   English   中英

从git-svn迁移到git后,如何删除伪造的远程分支?

[英]How do I remove fake remote branches I have after migrating from git-svn to git?

我使用git-svn已有一段时间了(我团队中的每个人都一直在直接使用svn)。 我们决定都将开始使用git。 为了做到这一点,我使用了git repo,它是我的git-svn的“一面”,例如:

$ git remote add origin git@github.com:mycompany/myproject.git
$ git push -u origin master

一切正常,但是当过程完成时,我保留了git-svn刚开始使用时创建的所有这些可笑的分支,只有一点点扭结。 git甚至不再承认它们是分支。 这是我的清单:

$ git branch -r
domain_integration
dot-org
dot-org@1977
email-edit-page
origin/account-integration
origin/master
origin/stable
prototype_to_jquery-1.1.0
stable@1976
tags/development-1.1.0.0
tags/pre-2011-02-08
tags/production-1.0
tags/stable-1.0.0
tags/stable-1.0.1
tags/stable-1.1.0
tags/stable-1.1.0.1
trunk-stash

这些很烦人,尽管我知道它们的来源(大部分是),但是现在我什至无法删除它们。 有时候是这样的:

$ git branch -d trunk-stash
error: branch 'trunk-stash' not found.

我可以通过进入.git / refs / remotes并删除它们来修复其中的一些问题,但是那里只有一些。 我只能在.git / info / refs中找到它们。 看起来类似于以下内容:

...
7788d300f0d4370d65a3ccf3e47d90f7fb16b0b4        refs/remotes/tags/stable-1.0.0
aace34d6745080ce2b6b29e927f5d1b050b99511        refs/remotes/tags/stable-1.0.1
58bd2ac23d5979ff61bd6305df18f8a5da50f888        refs/remotes/tags/stable-1.1.0
644fd55fcdf2569305cdbe0b6fefb9f247625658        refs/remotes/tags/stable-1.1.0.1
bc8e9f9177c9612aceb55624adea1b02e9e8620f        refs/remotes/trunk
69493e14345e6a7a4db324935bccd6393f201da4        refs/remotes/trunk-stash
25b7024f6c1d38c10400b2c2e7b446aae1e84e06        refs/stash
...

我认为这只是将分支与它们的最后一次提交相关联。 删除“假”的东西有意义吗? 这会破坏一些东西吗? (行得通吗?)

如果只需要master分支,则可以随时删除本地存储库并重新克隆它。 如果您只关心master分支,那是最简单的。 您可以随时尝试:

git remote prune origin

摆脱不再源于本地的远程引用。

暂无
暂无

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

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