When I found out that BitBucket added support for Git, I got pretty excited.
Just this past year I started to use Git as my DVCS for all my projects. More importantly, my older projects didn’t have any version control whatsoever. They were projects spread across multiple computers that only merged into a single external USB hard drive when I started to retire some computers because they were just too old (six plus years!).
Anyway, when this external drive began to make noises (clicking sounds), I decided I wanted to have my old projects stored in the cloud in case the the hard drive should ever fail.
Github was my goto host as it was immensely popular. At first I was on the free plan (unlimited public repos), but I decided my ugly legacy code shouldn’t be public, and went with their micro plan ($7 per month for 5 private repos). These projects are retired and there is no plan for future development. I just want them hosted with my other active personal projects.
I signed up for BitBucket not too long ago just because I wanted to play with Mercurial. That didn’t last very long. But with the new additional support for Git, and with the free unlimited private and personal projects, I knew I wanted to add this as a remote to also host all my projects.
But how was I to add another remote since I was already using Github? I wanted to add BitBucket as a remote along with Github. With a simple search on StackOverflow, I came across pull/push from multiple remote locations (answer).
Here is an example .git/config setting, with the bolded text the example text to add a remote:
[core] repositoryformatversion = 0 filemode = true bare = false logallrefupdates = true ignorecase = true [branch "master"] remote = origin merge = refs/heads/master [remote "origin"] url = email@example.com:sunpech/project_foo.git url = firstname.lastname@example.org:sunpech/project_foo.git fetch = +refs/heads/*:refs/remotes/origin/* [remote "heroku"] url = email@example.com:project_foo.git fetch = +refs/heads/*:refs/remotes/heroku/*
Now when I push changes, it pushes it to both Github and BitBucket. Simple, and it works. Hope this helps.
I have this setup because I may choose to abandon my Github pay account, and just host my public repos there, and all my private repos on BitBucket– saving me $7/month. Plus, I think it’s great for Github to have competition.