Pourquoi migrer
Mercurial et Git sont des systèmes frères. Migrer est principalement une question de tooling.
L'outil standard : fast-export
git clone https://github.com/frej/fast-export.git
cd ~/path-to-hg-repo
git init ../git-repo
cd ../git-repo
~/fast-export/hg-fast-export.sh -r ../path-to-hg-repo
git checkout HEAD
Mapping des auteurs
# authors.txt
"Jane Doe" = "Jane Doe <[email protected]>"
"bob" = "Bob Smith <[email protected]>"
~/fast-export/hg-fast-export.sh -r ../hg-repo -A authors.txt
Gestion des branches
Les named branches de Mercurial ne sont pas la même chose que les branches Git. Les bookmarks mappent plus proprement.
Branches fermées
git for-each-ref refs/heads/closed-* --format='%(refname:short)' \
| xargs -n 1 git branch -D
Tags
hg tags
git tag
Vérifier l'intégrité
hg log --template '{node}\n' | wc -l
git log --all --pretty=format:'%H' | wc -l
hg cat -r <hg-rev> path/to/file > /tmp/hg-file
git show <git-sha>:path/to/file > /tmp/git-file
diff /tmp/hg-file /tmp/git-file
Push vers un host Git
git remote add origin https://github.com/team/repo.git
git push -u origin --all
git push origin --tags
Traduction du workflow
hg pull équivaut à git fetch, pas git pull. hg commit commit tout ce qui est suivi; git commit commit l'index.
Extensions et hooks
mq → git rebase -i. histedit → aussi git rebase -i.
Soins après
Gardez le repo Mercurial en lecture seule pendant au moins un cycle de release.