Skip to content

Instantly share code, notes, and snippets.

@barseghyanartur
Forked from HerrPi/hg-to-git-conversion.md
Created February 7, 2020 19:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save barseghyanartur/4223a4406dc2e4a4bc9c2380c8df9a18 to your computer and use it in GitHub Desktop.
Save barseghyanartur/4223a4406dc2e4a4bc9c2380c8df9a18 to your computer and use it in GitHub Desktop.
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.

Prerequisites

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>/hg-fast-export.sh -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

Attention

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment