我覺得現在的版本控制主流已經是 git 了,但有一些 Open Source 專案的版本控制會選擇用 Mercurial (hg),這兩個版本控制系統有著不少相似的地方,都是不錯的工具。這篇主要教學如何將 hg 的專案移轉到 github 上,並保留所有的 commit 紀錄。

移轉方法

 以下的操作都是在 Ubuntu。首先安裝 hg 及下載 hg-git

$ apt install mercurial
$ pip install dulwich
$ hg clone http://bitbucket.org/durin42/hg-git/

   修改 ~/.hgrc,加入以下內容,如果沒有該檔案的話就建立一個

[extensions]
hgext.bookmarks =
hggit = path-to/hg-git/hggit

   clone 想要搬家的 hg project

$ hg clone https://hg-project
$ cd hg-project

   修改 hg 專案的 .hg/hgrc,在 Paths 標籤加入以下內容,注意 username 前面是 / 不是 :

[paths]
git = git+ssh://git@github.com/username/project.git

   bookmark default to git master

$ hg bookmark -r default master

   推上 github,這樣就完成囉!

$ hg push git

 

[參考資料來源](http://hg-git.github.io/ http://hgtip.com/tips/advanced/2009-11-09-create-a-git-mirror/)