Skip to content

Instantly share code, notes, and snippets.

@JMichaelVelasquez
Created November 27, 2016 21:03
Show Gist options
  • Save JMichaelVelasquez/ebd773bff27b9a1baa50800b61d95a55 to your computer and use it in GitHub Desktop.
Save JMichaelVelasquez/ebd773bff27b9a1baa50800b61d95a55 to your computer and use it in GitHub Desktop.
Migrating from BitBucket to GitHub
If you’re anything like me who didn't want to pay for github before their new business strategy, then most likely you use BitBucket or hosted your own (come ‘on, it was free!). Problem with that is now your activities or contributions are fragmented between the different services. Now that I've chosen GitHub, I found myself migrating the git repos.
Here is my copy and paste script I use for migration which also carries your history, which without it, defeats the purpose of it!
$ cd ~/Sites/repo-directory
$ git remote rename origin bitbucket
$ git remote add origin git@github.com:JMichaelVelasquez-change-user/your-new-repo.git
$ git push origin master
$ git remote rm bitbucket
Ok lets begin to break this down.
$ git remote rename origin bitbucket
This renaming or aliasing the origin to bitbucket is a great way to store both repos if intended to stay in contact with both for whatever reason.
$ git remote add origin git@github.com:JMichaelVelasquez-change-user/your-new-repo.git
Then you connect the repo to the new origin using the details on your project. I personally like to use SSH over HTTPS as it works best for me. But in this example
$ git push origin master
Push to your new master which is your GitHub repo. Warning, your repo might contain it’s own readme files or git ignores as GitHub creates one automatically if not careful. If that’s the case you will need to pull and merge the changes between the different remotes.
$ git remote rm bitbucket
The final stage and in turn, leaves the link to the BitBucket repo.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment