Skip to content

Instantly share code, notes, and snippets.

@vjwilson
Created March 27, 2015 19:23
Show Gist options
  • Save vjwilson/5b1ea56b7d622cb61ade to your computer and use it in GitHub Desktop.
Save vjwilson/5b1ea56b7d622cb61ade to your computer and use it in GitHub Desktop.
Convert an Mercurial repo to Git Repo with History, clean up authors, and rename branches
# based on Git docs: http://git-scm.com/book/en/v2/Git-and-Other-Systems-Migrating-to-Git
# in this case, I wanted to make the "stable" branch in Hg repo the "master" branch in Git,
# and remove the "default" branch, so that we could use new Git branches for feature development
git clone http://repo.or.cz/r/fast-export.git /tmp/fast-export
hg clone <path to Hg repo> /tmp/hg-repo
cd /tmp/hg-repo
hg log | grep user: | sort | uniq | sed 's/user: *//' > ../authors
vim ../authors # clean up author references
git init /tmp/converted
cd /tmp/converted
/tmp/fast-export/hg-fast-export.sh -r /tmp/hg-repo -A /tmp/authors
git br -m master master-old
git br -m stable master
git co master
git log
git br
git show-branch master master-old
git br -D master-old
# ******
# don't forget to push the new Git repo to a service, and clone it somewhere besides /tmp
# ******
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment