将Mercurial文件夹转换为Git存储库
我没有Mercurial的丰富经验,我主要是一个Git的家伙。
我很想在git Repository中镜像特定的Mercurial文件夹/文件。 我实际上想要做的是将文件的历史logging从Mercurial存储库导出到Git,并能够保持与未来的提交同步。
你有什么build议如何进行? 我相信要走的路要是获得Mercurial补丁的历史,定期将每个提交作为补丁导出,并将Mercurial补丁应用到Git存储库。
尝试快速导出 :
cd git clone git://repo.or.cz/fast-export.git git init git_repo cd git_repo ~/fast-export/hg-fast-export.sh -r /path/to/old/mercurial_repo git checkout HEAD Hg-Git扩展
Hg-Git可以用来将Mercurial仓库转换为Git。 您可以使用本地存储库或通过SSH,HTTP或HTTPS访问的远程存储库。
本地存储库转换的示例。
- 
安装Hg-Git。 - 
在Windows上, TortoiseHg带有Hg-Git,尽pipe你需要通过设置工具来启用它 (在扩展部分)   或者在 ~/mercurial.ini手动[extensions] hggit =
 
- 
- 
使用以下命令来转换存储库: $ mkdir git-repo; cd git-repo; git init; cd .. $ cd hg-repo $ hg bookmarks hg $ hg push ../git-repo
  hg书签是必要的,以防止问题,否则hg-git推送到当前签出的分支混淆Git。 这将在Git仓库中创build一个名为hg的分支。 为了获得master的更改,使用以下命令(只在第一次运行时需要,稍后使用git merge或rebase ): 
 $ cd git-repo $ git checkout -b master hg 
你可以(从Mercurial方面):
-  使用转换扩展名 --filemap选项将原始回购的一部分转换成更小,只有需要的文件目录
- 与hg-git扩展推卸载回购给Git
或者(而不是hg-git),使用Git中的Mercurial桥,从Git克隆|拉库
Gitify
似乎是一个更现代和易于使用的替代执行转换https://github.com/buchuki/gitifyhg
 pip install gitifyhg git clone gitifyhg::<hgrepoaddress> # done, you have a git repo with the entire history of the hg one 
我写了到底如何做到这一点: 使用Mercurial推送到GitHub 。 我一直在使用这种技术将一些Mercurial仓库推送到GitHub一年多,没有任何问题。