Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
A helper script to migrate mercurial repositories to gitlab/github
#!/bin/bash
set -e;
REPOUSER=mbarkhau
mkdir -p $HOME/workspace
cd $HOME/workspace
if ! [[ -d fast-export ]]; then
git clone https://github.com/frej/fast-export.git
fi
if ! [[ -d $1-hg ]]; then
hg clone ssh://hg@bitbucket.org/$REPOUSER/$1 $1-hg
fi
mkdir -p $1
cd $1
if ! [[ -d .git ]]; then
git init
$HOME/workspace/fast-export/hg-fast-export.sh -r ../$1-hg/
fi
git checkout HEAD
cat << EOF > .git/config
[core]
repositoryformatversion = 0
filemode = true
bare = false
logallrefupdates = true
[remote "origin"]
url = git@gitlab.com:$REPOUSER/$1.git
fetch = +refs/heads/*:refs/remotes/origin/*
[remote "gitlab"]
url = git@gitlab.com:$REPOUSER/$1.git
fetch = +refs/heads/*:refs/remotes/origin/*
[remote "github"]
url = git@github.com:$REPOUSER/$1.git
fetch = +refs/heads/*:refs/remotes/origin/*
[branch "master"]
remote = origin
merge = refs/heads/master
EOF
git push
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment