Convert Bitbucket Mercurial repositories to Git

Bjorn Heesakkers
1 min readMay 21, 2020

As mentioned in https://bitbucket.org/blog/sunsetting-mercurial-support-in-bitbucket, Bitbucket will stop support for Mercurial repositories per July 1, 2020 (the deadline was extended by 1 month).

How to convert your Mercurial repositories to Git? Simply follow these steps!

git clone git@github.com:frej/fast-export.git
  • Clone the Mercurial repository you want to convert:
hg clone ssh://hg@bitbucket.org/your_username/your_hg_repository
  • Create a new Git repository on Bitbucket and clone it:
git clone git@bitbucket.org:your_username/repository.git
  • cd into the cloned Git repository and run:
git config core.ignoreCase false
  • Then, convert the Mercurial repository by running (this assumes fast-export and your Mercurial repository is cloned into your $HOME directory):
~/fast-export/hg-fast-export.sh -r ~/your_hg_repository/
  • Checkout HEAD and push to the remote:
git checkout HEAD && git push

Done!

You can now delete your old Mercurial repository and continue using Git on Bitbucket.

--

--