Moving a local Mercurial Repository to Bitbucket

I recently got a new laptop.  Part of the migration process was to move a few local Mercurial repositories into Bitbucket.  Since these are just “playing around” repositories, they’ll be private, but the beauty of Bitbucket is that you get unlimited private repositories.  This allows me to keep all of my little pet projects “up in the cloud” and it’s one less thing to migrate the next time I get a new machine.

The process couldn’t be simpler:

1. Log in to your Bitbucket account.

2. Under “Repositories”, select “Create New Repository”.

3. Enter the details for your repository.  Make sure you check the “Private” checkbox if you want this private.

Once your new repository is created, grab the URL (either the HTTPS one or the SSH one – depending on what you’re using) and copy it to the clipboard.  Now go to your local mercurial repository and enter:

hg push [repositoryURL]

Where [repositoryURL] will be the URL of your new repository (that’s why you copied it to the clipboard!).

The one last thing you’ll want to do is change the default path to your repository to be the Bitbucket repository.  So the next time you need to push changes up to Bitbucket, it will know where to go.  To do this, edit the “hgrc” file located in the .hg directory of your repository.  If there’s not a “[paths]” section, add one and then add a “default” key with the URL of your new repository (again, the clipboard comes in handy!):

[paths]
default = https://...

Done!

Technorati Tags: ,

No Comments