descriptionPrograms to feed git-fast-import
last changeSun, 16 Aug 2015 15:13:04 +0000 (16 17:13 +0200)
content tags
hg-fast-export.(sh|py) - mercurial to git converter using git-fast-import


Most hg-* scripts are licensed under the MIT license[0] and were written
by Rocco Rutte <> with hints and help from the git list and
#mercurial on freenode. is licensed under GPLv2 since it
copies some code from the mercurial sources.

The current maintainer is Frej Drejhammar <>.


Using hg-fast-export is quite simple for a mercurial repository <repo>:

  mkdir repo-git # or whatever
  cd repo-git
  git init -r <repo>

Please note that hg-fast-export does not automatically check out the
newly imported repository. You probably want to follow up the import
with a "git checkout"-command.

Incremental imports to track hg repos is supported, too.

Using hg-reset it is quite simple within a git repository that is
hg-fast-export'ed from mercurial: -R <revision>

will give hints on which branches need adjustment for starting over

When a mercurial repository does not use utf-8 for encoding author
strings and commit messages the "-e <encoding>" command line option
can be used to force fast-export to convert incoming meta data from
<encoding> to utf-8.

As mercurial appears to be much less picky about the syntax of the
author information than git, an author mapping file can be given to
hg-fast-export to fix up malformed author strings. The file is
specified using the -A option. The file should contain lines of the
form "FromAuthor=ToAuthor". The example below will
translate "User <garbage<>" to "User <>".

-- Start of --
User <garbage<>=User <>
-- End of --

Tag and Branch Naming

As Git and Mercurial have differ in what is a valid branch and tag
name the -B and -T options allow a mapping file to be specified to
rename branches and tags (respectively). The syntax of the mapping
file is the same as for the author mapping.


hg-fast-export supports multiple branches but only named branches with
exactly one head each. Otherwise commits to the tip of these heads
within the branch will get flattened into merge commits.

As each git-fast-import run creates a new pack file, it may be
required to repack the repository quite often for incremental imports
(especially when importing a small number of changesets per
incremental import).

The way the hg API and remote access protocol is designed it is not
possible to use hg-fast-export on remote repositories
(http/ssh). First clone the repository, then convert it.

====== was designed in a way that doesn't require a 2-pass
mechanism or any prior repository analysis: if just feeds what it
finds into git-fast-import. This also implies that it heavily relies
on strictly linear ordering of changesets from hg, i.e. its
append-only storage model so that changesets hg-fast-export already
saw never get modified.

Submitting Patches

Please use the issue-tracker at github to report bugs and submit


2015-08-16 Frej DrejhammarAllow branches and tags to be remappedmaster
2015-08-16 Frej Drejhammarrefactor: Make author map loading more generic
2015-08-15 Frej DrejhammarSurvive corrupt source repositories
2014-11-01 zedMake -e option apply to imported filenames
2014-10-25 zedAdd option for specifying the text encoding used by...
2014-09-23 Frej DrejhammarDo not rely on "type -p"
2014-09-19 frejMerge pull request #37 from ottxor/master
2014-09-18 Christoph JunghansFix ROOT if hg-fast-export is in PATH
2014-07-06 Frej DrejhammarOnly dump heads in head cache
2014-05-30 ChrisUpdate README with note about no working directory
2014-05-02 Piotr ŚwięcickiAnnotate commits with the hg hash as git notes in the...
2014-04-13 Kyle J. replace egrep with grep
2014-03-28 Kyle J. do not sort merge commit parents
2014-03-16 frejMerge pull request #23 from ritcheyer/master
2014-03-16 Kyle J. improve authors file compatibility
2014-03-16 Kyle J. clean up help text and support ...
6 weeks ago master
8 years ago git-p4
8 years ago hanwen
Cached version (2920s old) 
fast-export/rorcz.git Local fork with... 14 months ago
fast-export/benizi.git 3 years ago
fast-export/fast-export-unix-compliant.git dereckson@espace... 3 years ago
fast-export/dharding.git 3 years ago
fast-export/barak.git tweaks and maybe debian packag... 3 years ago