简体   繁体   中英

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). We decided that we will all start using git. In order to do this, I used the git repo that is my "side" of git-svn like such:

$ 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 would no longer even acknowledge that they were branches. 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. The only other place i can find them is in .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. That's the easiest if you don't care about anything but the master branch. You can always try:

git remote prune origin

To get rid of remote references that are no longer in origin but kept locally.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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