When I first started playing with Python and Django, I was introduced to Mercurial. I had used Subversion for a while and once familiar with Mercurial, there was no going back (well…when I had the choice ;-) ). I’ve posted before that I use WebFaction as a host for my personal projects. This hosting also included setting up my own Hg server. I was happy, until Ken Cochrane turned me on to BitBucket.
I’ve been using BitBucket off and on for about a year now. My old projects have remained in my WebFaction repository, but my new projects have been going into BitBucket. No complaints. It has been solid and reliable. I can even setup SSH public keys for all my machines accessing the account. A plus when compared with my personal hosting.
So, it occurred to me. How do I convert all my projects over to BitBucket? As with most tasks I haven’t yet encountered I look to my friend Google to see if someone has solved the task in some trivial way. I should have realized how simple it was, but I’m glad I checked.
- Create a project at BitBucket.org
- Clone a repo from the old repository. Ensure everything is up to date with latest code and tags.
Change the .hg/hgrc file to point to the new Bit bucket repository
The old .hg/hgrc file
[paths] default = https://hg.my.hosting.site.url/myproject
The new .hg/hgrc file
[paths] default = ssh:[email protected]/user account/project name
- hg push
Yep, that’s all it took. I love Hg.
Inspired by Andrew Frayling’s post Bitbucket Import