Software Development/Migration_HG_Git

Migrating Mercurial (HG) to Git

Concepts (Read first)

Mercurial has branches (which we have used extensively: one ticket, one branch), and it has bookmarks (rearely used here). But Mercurial’s branches are more like full forks of a Git repository while Git’s branches rather correspond to Mercurial’s bookmarks.

The correct way to migrate a Mercurial repository with branches is to create a Git fork for each branch. But it is technically feasible to reflect all Mercurial branches into the same Git repository too. To accomplish that, every Mercurial branch, will need an auxiliary bookmark which is used to track the tip of that branch: a branch named “BRANCH-124-bis” will be bookmarked as “BRANCH-124-bis_git_pEpFnd”.

The setting in .hg/hgrg for this suffix is:


Install hg-git

First, find out what Python version your Mercurial is using:

hgpy=$(head -n1 $(which hg) | sed 's/^#!//' | tee -a /dev/stderr)
mkdir ~/pep-git-migration
cd ~/pep-git-migration
git clone
#  - or -
hg clone
cd hg-git
"$hgpy" -m pip install --user -e .
"$hgpy" -m pip install brotli ipaddress   # see (*) comment later on

Edit ~/.hgrc to add a line to the extensions section:

${EDITOR-nano} ~/.hgrc

hggit = ~/pep/code/repos/hg-git/hggit

At this point hg help should show an entry “git” (*):

$!hg help
Mercurial Distributed SCM

list of commands:


additional help topics:

 git           Working with Git Repositories

In my case, hg push $git_destination will later complain about missing modules, thus I add them manually earlier:

# "$hgpy" -m pip install brotli ipaddress

Mapping usernames in history: authors.txt

Where authors.txt is the name of a text file containing author name translations, one per each line, using the following format:

johnny = John Smith dougie = Doug Johnson

See if an authors.txt file is necessary:

hg log | grep ^user: | sort | uniq | grep -v \@

[ to be continued ]


For the following authors, name and email have to be defined manually

<name> = Anonymous <>
Alain Leufroy = x y <>
Alexey Sokolov = x y <>
Damiano Boppart = x y <>
David = x y <>
Dean = x y <>
Dean Looyengoed = x y <>
Edouard Tisserant = x y <>
Hussein Kasem = x y <>
Lix = x y <>
Thomas = x y <>
ana = x y <>
berna = x y <>
dulzet = x y <>
edouard = x y <>
fdik = Volker Birk <>
jsumners = x y <>
krista = x y <>
lix = x y <>
nana = x y <>
nikolaj = x y <>
nk = x y <>
vb = Volker Birk <>

Pre-Registered by Claudio: