Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Mercurial to Git repo conversion (hg-to-git)

Mercurial to Git repo conversion

Here is my personally successful approach to convert an existing Bitbucket hg repo to a new Bitbucket git repo. In this example, I invented a repo with the name "SimonSays". I used Windows 8.1.


hg-repo -> git-repo

Clone the original hg repo from Bitbucket

clone <bitbucket-link-to-SimonSays>

Initialize a new git repo

mkdir SimonSays-git
cd SimonSays-git
git init

Special git setting for the conversion script

git config core.ignoreCase false

Run the actual conversion script

Run it from within the directory of the newly created git repo

<path-to>/ -r <path-to>/SimonSays/

Should not report any errors.

Check out the git repo HEAD

git checkout HEAD

New git-repo -> Bitbucket

Create new Bitbucket git repo

Use Bitbucket's website to create a new git repo. In our example, we call it "SimonSays-git".

Clone locally converted git repo as bare

git clone --bare SimonSays-git
cd SimonSays-git.git

Change the remote to bitbucket and push all commits and tags to new Bitbucket git repo

git remote add bitbucket <link-to-SimonSays-git>
git push --all bitbucket
git push --tags bitbucket


The new Bitbucket git repo must not have the same name as the bare repo.


This comment has been minimized.

Copy link

barseghyanartur commented Feb 7, 2020

Thanks for sharing, I'll check it out one day soon.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.