46

I recently had an idea for a project. I found a project identical to the one I want to create on Github. I got very lucky because the person just started so there is a base, but everything is very raw and perfect for adding onto.

I made a fork of the project and made a big mistake. After I cloned the fork and committed changes to it I realized I wanted to rename the fork. Obviously this would have been easier to do from the start.

These are instructions from Github itself

When you rename a repository, its issues, wiki, stars, and followers are preserved. Forks continue to point to the root repository.

However, redirects are not set up for links that point to the old location. You will need to update your local repositories to point to the new location.

Which is great, i can simply rename the fork on Github but that leaves me repositories with the old links. How can I update my local repositories?

stevenmw
  • 689
  • 2
  • 8
  • 15
  • 9
    Note that that documentation is actually out of date: since [May 16](https://github.com/blog/1508-repository-redirects-are-here), GitHub does in fact create redirects. – Stuart P. Bentley Jun 24 '13 at 07:23
  • 1
    https://help.github.com/en/articles/renaming-a-repository – Suragch Mar 21 '19 at 17:58
  • Alternatively, you can [create a fork directly with a different name](https://stackoverflow.com/a/71849165/6309), since Apr. 2022. – VonC Apr 12 '22 at 21:12

1 Answers1

29

If you haven't renamed already, you can just push all pending changes, rename, and just clone again.

If you've already renamed, you should just update the origin on your local repos:

git remote set-url origin git://github.com/youruser/yourrepo
SheetJS
  • 22,470
  • 12
  • 65
  • 75
  • @stevenmw in that case you might find it easier to just push all pending changes from the various local repos, make sure everything is in sync, then rename and go back and just re-clone – SheetJS Jun 24 '13 at 05:17
  • 4
    FYI, Github is now performing redirections so you don't need to bother about git remotes anymore. "In addition to redirecting web traffic, all git clone, git fetch, or git push operations targeting the previous location will continue to function as if made on the new location." https://help.github.com/articles/renaming-a-repository – jackdbernier Aug 09 '14 at 22:24