{"id":243,"date":"2025-10-13T10:12:12","date_gmt":"2025-10-13T10:12:12","guid":{"rendered":"https:\/\/privateblog.nobytesleft.net\/?p=243"},"modified":"2025-10-13T10:21:33","modified_gmt":"2025-10-13T10:21:33","slug":"conversion-of-a-mercurial-repository-to-git","status":"publish","type":"post","link":"https:\/\/privateblog.nobytesleft.net\/?p=243","title":{"rendered":"Conversion of a Mercurial repository to Git"},"content":{"rendered":"\n<p>These instructions apply to Windows.<\/p>\n\n\n\n<p>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.<\/p>\n\n\n\n<p>Remember that <strong>everything<\/strong> must be committed into the original Hg repository to be migrated. If you don&#8217;t commit something, it will be lost.<\/p>\n\n\n\n<p>We will call the folder in which the Hg repository resides <strong><em>hg-repo<\/em><\/strong>, and the new folder in which the Git repository will be created <strong><em>git-repo<\/em><\/strong>.<\/p>\n\n\n\n<p>First of all we need an empty Git repository.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>&gt; md <em><strong>git-repo<\/strong><\/em><strong>\n<\/strong>&gt; cd <strong><em>git-repo<\/em><\/strong>\n&gt; git init<\/code><\/pre>\n\n\n\n<p>Then we push the Hg repository into the Git repository, using a bookmark as a reference.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>> cd <strong><em>hg-repo<\/em><\/strong>\n> hg bookmarks hg\n> hg push <strong><em>git-repo<\/em><\/strong><\/code><\/pre>\n\n\n\n<p>Now we can get a working copy in the Git repository folder.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>> cd <strong><em>git-repo<\/em><\/strong>\n> git checkout -b master hg<\/code><\/pre>\n\n\n\n<p>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 &#8220;master&#8221; instead of &#8220;main&#8221;, 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:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>&gt; cd <strong><em>git-repo<\/em><\/strong>\n&gt; git remote add origin https:\/\/<strong><em>gitea-server<\/em><\/strong>\/<strong><em>user<\/em><\/strong>\/<strong><em>repository.git<\/em><\/strong>\n&gt; git push -u origin master<\/code><\/pre>\n\n\n\n<p>This pushes the master branch. Everything can be pushed, and the previous history is preserved.<\/p>\n\n\n\n<p><\/p>\n","protected":false},"excerpt":{"rendered":"<p>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&hellip; <\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-243","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/privateblog.nobytesleft.net\/index.php?rest_route=\/wp\/v2\/posts\/243","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/privateblog.nobytesleft.net\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/privateblog.nobytesleft.net\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/privateblog.nobytesleft.net\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/privateblog.nobytesleft.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=243"}],"version-history":[{"count":4,"href":"https:\/\/privateblog.nobytesleft.net\/index.php?rest_route=\/wp\/v2\/posts\/243\/revisions"}],"predecessor-version":[{"id":249,"href":"https:\/\/privateblog.nobytesleft.net\/index.php?rest_route=\/wp\/v2\/posts\/243\/revisions\/249"}],"wp:attachment":[{"href":"https:\/\/privateblog.nobytesleft.net\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=243"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/privateblog.nobytesleft.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=243"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/privateblog.nobytesleft.net\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=243"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}