Moving from Mercurial and BitBucket to Git and GitHub

While skeptical at first, after trying it out github has won my favor as my favorite version control. This post records steps made to transfer from Mercurial and BitBucket to Git and GigHub while keeping history

Step 1 – Set up Password caching following article ‘Set Up Git’

Step 2 – Install git-hg module. This allows to clone a mercurial repository from BitBucket and then converts it to git repository that you can push into the GitHub.com

Followed article ‘Moving Your Mercurial To Rep To Git’

Step 3 – Clone the existing GitHub repository and push it to GitHub as following:

git-hg clone http://bitbucket.org/some/repo name-git-repo
cd name-git-repo
git remote add origin http://github.com/some/repo.git
git push origin master

Potential Issues

1. “fatal: remote part of refspec is not a valid name in .”
This happens when you created new branch that you would like to push into github repo while the github repo doesn’t contain the new brach. Solutions:

git config push.default current

This will change default setting for ‘push’ to create new branch in the github repo if doesn’t exist before pushing. Here are other options:

  • nothing : Do not push anything
  • matching : Push all matching branches (default)
  • tracking : Push the current branch to whatever it is tracking
  • current : Push the current branch

Useful Links

Leave a Reply

Your email address will not be published. Required fields are marked *