Git 与 Mercurial 存储库的互操作性 [英] Git interoperability with a Mercurial Repository

查看:17
本文介绍了Git 与 Mercurial 存储库的互操作性的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在 Mac 上使用 GIT.说够了.我有工具,我有经验.我想继续使用它.这里没有战争...

I use GIT on a Mac. Enough said. I have the tools, I have the experience. And I want to continue to use it. No wars here...

问题始终在于互操作性.大多数人使用 SVN,这对我来说很棒.Git SVN 开箱即用,是一种简洁的解决方案.人们可以继续愉快地使用 SVN,而且我不会丢失我的工作流程和我的工具.

The problem is always with interoperability. Most people use SVN, which is great for me. Git SVN works out of the box, and is a no frills solution. People can continue happily use SVN and I don't lose my workflow and neither my tools.

现在...有些人会和 Mercurial 一起来.对他们来说很好:他们有他们的理由.但是我找不到任何开箱即用的 GIT HG.我不想切换到 HG,但我仍然需要与他们的存储库进行互操作.

Now... Some guys come along with Mercurial. Fine for them: they have their reasons. But I can't find any GIT HG out-of-the-box. I don't want to switch to HG, but I still need to interoperate with their repository.

你们中有人知道一个简单的解决方案吗?

Any of you guys know a simple solution for this?

推荐答案

从 2012 年 6 月更新.当开发者想从 git 端工作时,目前似乎有以下方法用于 Git/Hg 互操作性:

Update from June 2012. Currently there seem to be the following methods for Git/Hg interoperability when the developer wants to work from the git side:

  1. 安装 Mercurial 和 hg-git 扩展.您可以使用包管理器或 easy_install hg-git 来完成后者.然后确保以下内容在您的 ~/.hgrc 中:

  1. Install Mercurial and the hg-git extension. You can do the latter using your package manager, or with easy_install hg-git. Then make sure the following is in your ~/.hgrc:

[extensions]
hggit = 

您可能会在此处看到一些关于指定 bookmarks 扩展的参考资料,但自 v 1.8 以来,Mercurial 已内置该扩展.这里是 关于在 Windows 上安装 hg-git 的一些提示.

You may see some references that talk about specifying the bookmarks extension here too, but that has been built into Mercurial since v 1.8. Here are some tips about installing hg-git on Windows.

一旦你有了 hg-git,你就可以使用类似于 Abderrahim Kitouni 上面发布的命令.这个方法已经自 2009 年以来经过改进和调整,并且有一个友好的包装器:git-hg-again.这同时使用顶层目录作为 Mercurial 和 Git 的工作目录.它创建一个 Mercurial 书签,它与 Mercurial 存储库中 default(未命名)分支的提示保持同步,并从该书签更新本地 Git 分支.

Once you have hg-git, you can use commands roughly like Abderrahim Kitouni posted above. This method has been refined and tweaked since 2009 though, and there is a friendly wrapper: git-hg-again. This uses the toplevel directory as a working directory for both Mercurial and Git at the same time. It creates a Mercurial bookmark that it keeps in synch with the tip of the default (unnamed) branch in the Mercurial repository, and it updates a local Git branch from that bookmark.

  1. git-remote-hg是一个不同的包装器,也基于 Mercurial hg-git 扩展.这还使用了 git-remote-helpers 协议(因此得名).它仅将顶层目录用于 Git 工作目录;它保持其 Mercurial 存储库裸露.它还维护了第二个裸 Git 存储库,使 Git 和 Mercurial 之间的同步更安全,更像 git-like.

  1. git-remote-hg is a different wrapper, also based on the Mercurial hg-git extension. This additionally makes use of the git-remote-helpers protocols (hence its name). It uses the toplevel directory only for a Git working directory; it keeps its Mercurial repository bare. It also maintains a second bare Git repository to make synching between Git and Mercurial safer and more idiomatically gitlike.

git-hg 脚本(以前是此处) 使用不同的方法,基于 hg-fast-export来自快速导出项目.与方法 2 一样,这也保留了一个裸 Mercurial 存储库和一个额外的裸 Git 存储库.

The git-hg script (formerly maintained here) uses a different method, based on hg-fast-export from the fast-export project. Like method 2, this also keeps a bare Mercurial repository and an additional bare Git repository.

对于拉取,此工具会忽略 Mercurial 书签,而是将每个命名的 Mercurial 分支导入 Git 分支,并将默认(未命名的)Mercurial 分支导入 master.

For pulling, this tool ignores Mercurial bookmarks and instead imports every named Mercurial branch into a Git branch, and the default (unnamed) Mercurial branch into master.

一些评论讨论此工具仅适用于 hg->git,但它声称已于 2011 年 12 月 7 日合并到 git->hg 推送支持中.正如我在 对这些工具的回顾,但是,这个工具试图实现推送支持的方式似乎并不可行.

Some commentary discusses this tool as being hg->git only, but it claims to have merged in git->hg push support on 7 Dec 2011. As I explain in a review of these tools, though, the way this tool tries to implement push support doesn't seem to be workable.

  1. 还有另一个名为git-remote-hg.与上面列出的版本不同,这个版本不依赖于 hg-git,而是直接访问 Mercurial Python API.目前,使用它还需要一个补丁版本的 git.这个我还没试过.

  1. There's also another project called git-remote-hg. Unlike the version listed above, this one doesn't rely on hg-git, but instead directly accesses the Mercurial Python API. At the moment, using it also requires a patched version of git. I haven't tried this yet.

最后,Tailor 是一个增量转换的项目在各种不同的 VCS 之间.听起来好像不会积极地继续开发.

Finally, Tailor is a project that incrementally converts between a variety of different VCSs. It sounds like development of this won't be aggressively continued.

前三种方法看起来足够轻量级,足以说服我进行调查.我需要以某种方式调整它们以使它们在我的设置上运行,我看到了一些进一步调整它们以改进它们的方法,然后我进一步调整它们以使它们表现得更像彼此,以便我可以评估他们更有效.然后我想其他人可能也喜欢进行这些调整,以进行相同的评估.所以我已经制作了一个源包,可以让你安装我的前三个版本中的任何一个工具.它还应该负责安装所需的 hg-fast-export 部分.(您需要自己安装 hg-git.)

The first three of these approaches looked lightweight enough to persuade me to investigate. I needed to tweak them in some ways to get them to run on my setup, and I saw some ways to tweak them further to improve them, and then I tweaked them still further to make them behave more like each other so that I could evaluate them more effectively. Then I thought others might like to have these tweaks too, to do the same evaluation. So I've made a source package that will enable you to install my versions of any of the first three tools. It should also take care of installing the needed hg-fast-export pieces. (You need to install hg-git on your own.)

我鼓励您尝试一下,然后自己决定什么最有效.我很高兴听到这些工具失效的情况.我会尽量让它们与上游更改保持同步,并确保上游作者了解我认为有用的调整.

I encourage you to try them out and decide for yourself what works best. I'll be glad to hear about cases where these tools break. I'll try to keep them in synch with upstream changes, and to make sure the upstream authors are aware of the tweaks I think are useful.

正如我上面提到的,在评估这些工具时,我得出的结论是 git-hg 只能用于从 Mercurial 中拉取,不能用于推送.

As I mentioned above, in evaluating these tools, I came to the conclusion that git-hg is only usable for pulling from Mercurial, not for pushing.

相关地,这里有一些 Git 和 Mercurial 之间有用的比较/翻译手册,在某些情况下针对已经了解 Git 的用户:

Relatedly, here are some useful comparisons/translation manuals between Git and Mercurial, in some cases targetted at users who already know Git:

这篇关于Git 与 Mercurial 存储库的互操作性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆