3

I recently moved my 'main' remote git repository from code.google to github. Then, I renamed old origin repo to code-google and previously created remote github to origin. So far so good.

But...

There are still references in .git/refs/remotes:

code-google  github  origin

I tried this, but it does not seem to be working:

$ git remote prune github --dry-run
fatal: 'github' does not appear to be a git repository
fatal: The remote end hung up unexpectedly

Why is github still there since it was renamed? Why am I not able to dispose of it? And how can I clean up my repo?

Pavel S.
  • 11,892
  • 18
  • 75
  • 113
  • If you had used `git remote rename code-google origin`, you wouldn't had them hanging around in the first place as git would've moved the refs under the new name. Also, just deleting '.git/refs/remotes/' doesn't guarantee all of them are gone. Git also has packed refs, which are not stored as separate files on the file system. Just thought you'd like to know for the next time around. – John Szakmeister Jan 20 '13 at 18:09
  • Well, `git remote rename x y` is exactly what I had used. – Pavel S. Jan 20 '13 at 21:09
  • 1
    If you did that, then git may have left behind empty folders, but the refs should have all been migrated. If that isn't what happened, I'd report it to the git list because I suspect that would be a bug. – John Szakmeister Jan 21 '13 at 00:49
  • BTW, what does `git ls-remote .` show? – John Szakmeister Jan 21 '13 at 00:51
  • Just the branches from new origin (@github.com) – Pavel S. Jan 21 '13 at 09:38
  • And yes, the other directories are empty, only `origin` contains something (branche names). – Pavel S. Jan 21 '13 at 09:40

1 Answers1

3

This thread (now deleted) mentions that renaming the remote isn't enough:

If you want to be really complete, you should also delete your 'origin' refs :

rm -R .git/refs/remotes/origin

A safer way would be to clone your new remote repo (now on GitHub), and add another remote.

VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250