5 Easy Steps to Archive a Github Repo on Bitbucket
So I love Github. I use it for personal projects and for work. I’m happy to pay for the service but I find myself constantly running out of space because of old private repos. Most of the time these finished (or abandoned) projects are not worth keeping around. Bitbucket offers free unlimited private repos, so using it for archiving projects seems like a great option.
Here’s the easy guide to archiving (or moving) a project from Github to Bitbucket.
1. Import the Github repository to Bitbucket
Probably the easiest part. Bitbucket has implemented a flawless Import your GitHub repositories feature. Authenticate with Github and you are done (Bitbucket will send out an email once the import is complete). If your project was private in Github it’ll still be private once it gets ported to Bitbucket.
2. Add the new Bitbucket remote on your local machine
This will allow you to use bitbucket as another remote should you want to continue doing development.
git remote add bitbucket <https://omarrr@bitbucket.org/omarrr/PROJECT>
Check your setup to make sure all is good.
git remote -v
bitbucket https://omarrr@bitbucket.org/omarrr/PROJECT.git (fetch)
bitbucket https://omarrr@bitbucket.org/omarrr/PROJECT.git (push)
origin git@github.com:omarrr/PROJECT.git (fetch)
origin git@github.com:omarrr/PROJECT.git (push)
3. Setup the new origin repo
If you are going to delete the repo from Github and —potentially— start using Bitbuket instead, you’ll want to setup origin
to point to the new Bitbucket remote instead of Github. We do this so that we can keep working with the new repo as if it was the old one by pushinng and pulling to Bitbucket as the default remote.
git remote rename origin github
git remote rename bitbucket origin
Again, check that everything is good
git remote -v
github git@github.com:omarrr/PROJECT.git (fetch)
github git@github.com:omarrr/PROJECT.git (push)
origin https://omarrr@bitbucket.org/omarrr/PROJECT.git (fetch)
origin https://omarrr@bitbucket.org/omarrr/PROJECT.git (push)
4. Done!
Since your project is safe in Bitbucket now, you can delete it from Github. You can see below how to.
4.1. Create a backup or clone (Optional)
Clone your repo to retrieve a copy of the full history of your project with all branches, tags, etc.
git clone <https://omarrr@bitbucket.org/omarrr/PROJECT>
Generate a ZIP
tar -cf <PROJECT>.ZIP <PROJECT/>
Delete the clone
rm -rf <PROJECT>
4.2 Delete the project from Github (Optional)
It’ll be a good idea to confirm that Bitbucket has been properly setup and/or create a clone of the repo (see above) before proceeding (just saying).
Go to the “Danger Zone™” in the project settings page on Github (eg: https://github.com/omarrr/PROJECT/settings
) and click “Delete this Repository”.
Finally remove the remote from your local machine
git remote rm github
Once more, check that everything is good
git remote -v
origin https://omarrr@bitbucket.org/omarrr/PROJECT.git (fetch)
origin https://omarrr@bitbucket.org/omarrr/PROJECT.git (push)
5. Done!
No, really. We are done now.