Convert Mercurial project to Git [duplicate]


I need to convert a mercurial project to a git project, but I would like to keep the commit history intact. My current solution was to just remove hg related files and then git init && add manually the files I needed, but that would not keep the history. Are there any solutions to this?


You can try using fast-export:

cd ~
git clone
git init git_repo
cd git_repo
~/fast-export/ -r /path/to/old/mercurial_repo
git checkout HEAD

Also have a look at this SO question.

If you're using Mercurial version below 4.6, adrihanu got your back:

As he stated in his comment: "In case you use Mercurial < 4.6 and you got "revsymbol not found" error. You need to update your Mercurial or downgrade fast-export by running git checkout tags/v180317 inside ~/fast-export directory.".

When do you use Git rebase instead of Git merge?

How would I extract a single file (or changes to a file) from a git stash?