Mercurial is a great source control system with good tooling and cross-platform support, but it’s kind of slow when repositories get bigger. At least this is my experience with large repositories, Mercurial and Bitbucket.
Example of Mercurial being slow for large Repositories
The cloning of the “PowerShell-Workshop” repository from Bitbucket which contains quite of lot of screenshots and other binary data took more than 30 minutes - even though the repo has only a size of about 50 MB:
- Install and configure git
- Install and configure mercurial
- A mercurial repository that you want to convert to a git repository
Steps to convert a repository
You basically only need to follow the steps described in the README of the fast-export project at https://github.com/frej/fast-export.
Get fast-export from Github
fast-export or hg-fast-export is a shell/python script which used git-fast-import to convert mercurial repositories to git.
git clone git://github.com/frej/fast-export.git
Clone the Mercurial Repository you want to convert
This might take a while if the repository is big. This is one reason why you might want to switch from Mercurial to Git.
hg clone https://bitbucket.org/andreaskoch/powershell-workshop
Create a new git repository
This will be the target for your export from mercurial.
cd ~/dev/git mkdir PowerShell-Workshop cd PowerShell-Workshop git init
Execute hg-fast-export.sh in your new git repository
cd ~/dev/git/PowerShell-Workshop ~/git/fast-export/hg-fast-export.sh -r ~/dev/hg/powershell-workshop
For some strange reason hg-fast-export.sh deleted all files in the new repository after it converted everything successfully.
To fix this you can just unstage the changes and everything should be fine:
git reset HEAD^ git checkout . git status git log
After the repo has been converted
All that is left to do is change your .hgignore files to .gitignore files.