With decision to move away from Git, next big step was to transfer existing repositories. While there is a semi-reasonable Git support on Windows, any major dealing with Git is made much easier if you have Linux laying around. In my case decision was to deal with CentOS.
First step was to install all stuff we’ll need – Git, Mercurial and git-remote-hg script:
yum -y install git
yum -y install mercurial
yum -y install wget
wget https://raw.github.com/felipec/git-remote-hg/master/git-remote-hg -O ~/bin/git-remote-hg
chmod +x ~/bin/git-remote-hg
With that it was time to clone the first repository:
git clone hg::https://bitbucket.org/jmedved/vhdattach
In ideal world this would be all and we are close. If omitted, this step would skip reproducing branching structure on Git. But, while we are at it, I wanted to recreate branching structure I’m used to. Since conversion process leaves all branches inside
remotes/origin/branches path, I wanted to move things around a bit:
git branch -a | grep 'remotes/origin/branches' | grep -v default | xargs -n 1 -I _ echo _ | cut -d/ -f 4 | xargs -n 1 -I _ git branch _ remotes/origin/branches/_
Next (optional) step was to fix my old commits:
git filter-branch --env-filter '
if [ "$GIT_COMMITTER_EMAIL" = "$OLD_EMAIL" ]
if [ "$GIT_AUTHOR_EMAIL" = "$OLD_EMAIL" ]
' --tag-name-filter cat -- --branches --tags
Since my move to Git was intended to be final I also wanted to change origin. My new home was to be GitHub:
git remote rm origin
git remote add origin email@example.com:medo64/vhdattach.git
git push --all
With that my move was complete.
[2020-05-01: There is a bit newer version of this guide.]