[git] 從 hg 換到 git (windows 10)

  • 3951
  • 0

如何將 hg repo 換成 git repo

目前主要趨勢底定是 git。得要先把 hg 的專案轉到 git 來。

我在 windows 有裝 tortoisehg,所以作法如下:

(1) 在 tortoisehg 的 global settings 裡,把 extension hggit 打開。
(2) 在 bitbucket 開一個 git repo。假設路徑為 https://bitbucket.org/username/hg-projectname-git
(3) 在原來的 hg 的目錄下,執行以下命令,產生 git 的頭:
hg bookmark -r default master
(4)  在原來的 hg 的目錄下,執行以下命令,把歷史推上去:
hg push git+https://bitbucket.org/username/hg-projectname-git
(5) 用 git clone 新路徑。之後就用這個新的 git clone 目錄工作。

打完收工

注意事項:

(1) tortoiseplink 已經失效,所以 hg push git+ssh 這個指令會失敗。我找不到辦法換成 ssh.exe,所以就用 https 的方式。
(2) hg push 的路徑不要用 https://username@bitbucket.org 這種,hg 會產生 getaddrinfo 錯誤。

主要參考文章三篇:
http://arr.gr/blog/2011/10/bitbucket-converting-hg-repositories-to-git/

https://mcmblog.azurewebsites.net/using-tortoisehg-with-git/

https://stackoverflow.com/questions/9272233/hg-clone-using-mercurial-throws-getaddrinfo-failed-error-windows-7

 

 

 

分享