Report inadequate content

Migrating a Github repo to Bitbucket (or similar services)


 TAGS:Github is awesome. Bitbucket is awesome too. They are both excellent services, but Bitbucket has a plus: it's free for private repos.

That's one of the reasons on why we decided to stop paying our $25/mo Github account for small projects and moved to Bitbucket. Although the Bitbucket guys have now a one-click "import from Github tool", the solution is so simple that I don't even think it is worth using it. Because at the end of the day, even if you uset it you'll need to change by hand where your origin points to anyway.

The following example is a Github to Bitbucket migration keeping the same files (no other clone needed). You can use this code for any service though, it works with any git repo:

First of all create your new blank repository and then go to your shell and do:

git pull
git push --mirror
git remote set-url origin
# or the same using HTTPS:
# git remote set-url origin

 These three lines do the following:

  • Get the last changes from your current origin
  • Copy the entire repository (with all the commit data) to the new origin
  • Change the old origin to the new location

After this you can git pull/push/whatever as if nothing happened. You don't need to clone anything again. You have Github migrated to Bitbucket!




Comments Migrating a Github repo to Bitbucket (or similar services)

Hey Albert,
Amazing 3 lines of code.
Thanks for sharing bro.
God bless your life,
Leniel Macaferi Leniel Macaferi 25/11/2013 at 23:58

Leave your comment Migrating a Github repo to Bitbucket (or similar services)

Log in to Obolog, or create your free blog if you are not registered yet.

User avatar Your name