Created
May 17, 2012 06:13
-
-
Save NickJosevski/2716901 to your computer and use it in GitHub Desktop.
A neat migration bash script for migration of Hg to Git, from Paul Jenkins
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Requirements: Hg, Hg-Git, Git Bash | |
#!/bin/sh | |
hg clone $2 $1 | |
cd $1 | |
hg bookmark -r default master | |
hg gexport | |
mv .hg/git .git | |
rm -rf .hg | |
git init | |
git checkout master -f | |
git filter-branch --env-filter ' | |
an="$GIT_AUTHOR_NAME" | |
am="$GIT_AUTHOR_EMAIL" | |
cn="$GIT_COMMITTER_NAME" | |
cm="$GIT_COMMITTER_EMAIL" | |
if [ "$GIT_AUTHOR_NAME" = "user1" ] | |
then | |
cn="user1" | |
cm="user1s@email" | |
an="user1" | |
am="user1s@email" | |
fi | |
if [ "$GIT_AUTHOR_NAME" = "user2" ] | |
then | |
cn="users2name" | |
cm="user2s@email" | |
an="users2name" | |
am="user2s@email" | |
fi | |
export GIT_AUTHOR_NAME="$an" | |
export GIT_AUTHOR_EMAIL="$am" | |
export GIT_COMMITTER_NAME="$cn" | |
export GIT_COMMITTER_EMAIL="$cm" | |
' | |
git remote add origin $3 | |
git push origin master | |
Usage | |
./hg_git_with_fixes <name> <hg clone url> <git push url> | |
ie | |
./hg_git_with_fixes mahappsmetro https://bitbucket.org/aeoth/mahapps.metro [emailprotected]:MahApps/MahApps.Metro.git |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment