简体   繁体   English

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

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

I've been using git-svn for a while (everyone else on my team has been using svn directly). 我使用git-svn已有一段时间了(我团队中的每个人都一直在直接使用svn)。 We decided that we will all start using git. 我们决定都将开始使用git。 In order to do this, I used the git repo that is my "side" of git-svn like such: 为了做到这一点,我使用了git repo,它是我的git-svn的“一面”,例如:

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

This went fine, but when the process was complete I had retained all these ridiculous branches that git-svn had created when I first started using it, with one little kink; 一切正常,但是当过程完成时,我保留了git-svn刚开始使用时创建的所有这些可笑的分支,只有一点点扭结。 git would no longer even acknowledge that they were branches. git甚至不再承认它们是分支。 Here's what my list looked like: 这是我的清单:

$ 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

These were annoying, though I knew where they came from (mostly), but now I can't even delete them. 这些很烦人,尽管我知道它们的来源(大部分是),但是现在我什至无法删除它们。 This happens: 有时候是这样的:

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

I was able to fix some of these by going into .git/refs/remotes and just deleting them, but there were only a few there. 我可以通过进入.git / refs / remotes并删除它们来修复其中的一些问题,但是那里只有一些。 The only other place i can find them is in .git/info/refs. 我只能在.git / info / refs中找到它们。 Which looks something like the following: 看起来类似于以下内容:

...
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
...

I assume this is just associated the branches with their last commits. 我认为这只是将分支与它们的最后一次提交相关联。 Does it make sense to delete the "fake" ones? 删除“假”的东西有意义吗? Will this break something? 这会破坏一些东西吗? (Will it work?) (行得通吗?)

If you only want the master branch you can always delete the local repo and re-clone it. 如果只需要master分支,则可以随时删除本地存储库并重新克隆它。 That's the easiest if you don't care about anything but the master branch. 如果您只关心master分支,那是最简单的。 You can always try: 您可以随时尝试:

git remote prune origin

To get rid of remote references that are no longer in origin but kept locally. 摆脱不再源于本地的远程引用。

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

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