Bitbucket withdraws Mercurial repositories support and pretty soon will remove Mercurial repositories completely. In order to still use Bitbucket service those of you who had been using Mercurial repositories have to convert them to Git. Here is a couple of Bash and PHP scripts that helps to migrate Bitbucket Mercurial repositories to Git.
Warning: This utility creates private git copies of your hg repos. If you need to make them public you can do it in repo settings at bitbucket.org.
- hggit
Mercurial
plugin must be installed and set up PHP 7.*
and Composer must be installed- SSH keys Bitbucket authentication must be set up
Follow these steps:
- Run
composer install
insrc/php_scripts
folder - it will install libraries needed for PHP scripts - Run
convert.sh yourBitbucketAccount yourBitbucketPassword
- this will copy all your Bitbucket Mercurial repositories to Git repositories with names like "git_originalMercurialRepositoryName" - Thoroughly check all converted repositories on Bitbucket (with names like "git-git_yourMercurialRepositoryName"), and if everything is OK then (AND ONLY THEN) do whatever you want with your Bitbucket Mercurial repositories - for example, remove them
You can also convert repositories in semi-automatized mode - follow these steps:
- Run:
migrate.sh yourBitbucketAccountName yourBitbucketAccountPassword
- it will clone create Mercurial repository inyourRepositoryName-hg
folder and convert it to a bare Git repository inyourRepositoryName-git
folder - Manually create Bitbucket Git repository called
git_yourRepositoryName
- Run *
push_to_remote_git.sh yourBitbucketAccountName yourRepositoryName
- it will push local Git repository fromyourRepositoryName-git
folder to a remote Bitbucket Git repository that you created on previous step Or justconvert_repo.sh
script that runs sequentiallymigrate.sh
andpush_to_remote_git.sh
with provided arguments. You can use it like thisrun.sh yourBitbucketAccountName yourRepositoryName
, but do not forget to create Bitbucket Gitgit_yourRepositoryName
repository before running it.
I do not take any responsibility for any harm that could be done with these scripts to your repositories, however I didn't included any intentionally harmful actions in them. Just carefully check that yours Mercurial repositories were correctly converted to Git before repositories removing originals repositories.
- (c) 2020 Sergey Lebedev, licensed under the Apache License, Version 2.0
- Feel free to contact me at: