Conversion of a Mercurial repository to Git
These instructions apply to Windows.
We use hg-git, which is installed by default with TortoiseHg version 7.0.1. Note that with a previous version we had problems, so it is necessary to upgrade first.
Remember that everything must be committed into the original Hg repository to be migrated. If you don’t commit something, it will be lost.
We will call the folder in which the Hg repository resides hg-repo, and the new folder in which the Git repository will be created git-repo.
First of all we need an empty Git repository.
> md git-repo
> cd git-repo
> git init
Then we push the Hg repository into the Git repository, using a bookmark as a reference.
> cd hg-repo
> hg bookmarks hg
> hg push git-repo
Now we can get a working copy in the Git repository folder.
> cd git-repo
> git checkout -b master hg
Then we push the Git repository to a new repository in Gitea. In Gitea, we create a new empty repository. We also choose the default branch to be “master” instead of “main”, but any choice will do. The gitea creation process will tell you how you can push to the repository, but we use HTTPS and not the GIT protocol. So:
> cd git-repo
> git remote add origin https://gitea-server/user/repository.git
> git push -u origin master
This pushes the master branch. Everything can be pushed, and the previous history is preserved.