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

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

问题描述

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



问题始终在于互操作性。大多数人使用SVN,这对我很好。 Git SVN开箱即用,并且是一个没有装饰的解决方案。人们可以继续高兴地使用SVN,我不会失去我的工作流程,也不会失去我的工具。



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



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

解决方案

从2012年6月开始更新。当开发人员希望从git工作时,目前似乎有以下Git / Hg互操作性方法: 安装Mercurial和 hg-git扩展 。你可以使用你的软件包管理器,或使用 easy_install hg-git 来完成后者。然后确保〜/ .hgrc中包含以下内容:

  [extensions] 
hggit =

您可能会看到一些引用,指出指定书签扩展名在这里也是如此,但自1.8版以来,这已经被纳入Mercurial。这里是关于在Windows上安装hg-git的一些提示



一旦你有了hg-git,你可以使用类似 Abderrahim Kitouni张贴在上面。此方法已被自2009年以来进行了改进和调整,但有一个友好的包装: <强> GIT-HG-再次 。这将同时使用顶级目录作为Mercurial和Git的工作目录。它创建一个Mercurial书签,它与Mercurial存储库中的默认(未命名)分支的提示保持同步,并从该书签更新本地Git分支。 / p>

  • git- remote-hg 是一个不同的包装,它也基于Mercurial hg-git 扩展名。这另外使用了 git-remote-helpers 协议(因此它的名字)。它仅将顶级目录用于Git工作目录;它保持其Mercurial存储库裸露。它还维护第二个裸Git仓库,以便在Git和Mercurial之间更安全和更习惯地使用gitlike。

  • .com / cosmin / git-hgrel =nofollow noreferrer> git-hg 脚本(以前保持 here )使用另一种方法,基于 //repo.or.cz/w/fast-export.gitrel =nofollow noreferrer> 快速导出项目 。与方法2一样,这也会保留一个纯粹的Mercurial存储库和一个额外的裸露Git存储库。



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



    有些评论将这个工具作为hg-> git讨论,但它声称已经合并到git中 - > 2011年12月7日hg推送支持。正如我在对这些评论工具,但该工具尝试实施推送支持的方式似乎不可行。 还有 另一个名为git-remote-hg 的项目 。与上面列出的版本不同,这个版本不依赖于hg-git,而是直接访问Mercurial Python API。目前,使用它还需要修补版本的git。我还没有尝试过。 > 裁缝 是一个在各种不同的VCS之间进行增量式转换的项目。这听起来像这样的发展将不会积极地继续。

    这些方法的前三个看起来足够轻量级说服我去调查。我需要以某种方式调整它们以使它们在我的设置上运行,并且我看到了一些方法来进一步调整它们以改善它们,然后我进一步调整它们以使它们更像彼此的行为,以便我可以评估他们更有效。然后,我认为其他人也可能喜欢做这些调整,以进行相同的评估。因此,我制作了一个源代码包,这将使您能够安装前三个版本中的任意一个工具。它还应该负责安装所需的 hg-fast-export 部分。 (您需要自行安装 hg-git )。



    我鼓励您尝试并决定为自己最好的。我会很高兴听到这些工具中断的情况。我会尽量保持它们与上游变化同步,并确保上游作者知道我认为有用的调整。



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



    相关地,下面是Git和Mercurial之间的一些有用的比较/翻译手册,在某些情况下针对已知Git的用户:

  • Git用户的Mercurial

  • < git和mercurial - 比较和对比

  • Mercurial和Git有什么区别
  • >
  • Mercurial和Git:技术比较 Git hg rosetta stone

  • Homebrew Coding:Mercurial

  • Francisoud的博客:Git vs Mercurial(hg)

  • Git vs Mercurial


  • 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...

    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.

    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?

    解决方案

    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. 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 = 
      

      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.

      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.

    2. 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.

    3. 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.

      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.

      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.

    4. 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.

    5. 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.

    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.

    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.

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

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

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