如何将 git 存储库转换为 mercurial?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/491554/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-10 06:07:36  来源:igfitidea点击:

How do I convert a git repository to mercurial?

gitversion-controlmercurialtortoisehg

提问by Spoike

I've been developing a java application using git as source code repository. I'd like to share the project with other java developers and hg seems to be most used by them.

我一直在使用 git 作为源代码存储库开发 Java 应用程序。我想与其他 Java 开发人员共享该项目,他们似乎最常使用 hg。

My question is how do I convert a git repository to hg?

我的问题是如何将 git 存储库转换为 hg?

If I tried googling "convert git to hg" and every search hit is about converting from hg to git. I'm also using TortoiseHg.

如果我尝试使用谷歌搜索“将 git 转换为 hg”,并且每次搜索命中都是关于从 hg 转换为 git。我也在使用TortoiseHg

采纳答案by Spoike

The hg convertutility isn't on by default after installation. In order to set it as such add the following to your .hgrcfile.

hg convert安装后默认情况下该实用程序未启用。为了将其设置为这样,请将以下内容添加到您的.hgrc文件中。

[extensions]
hgext.convert=

If you're using TortoiseHgon Windows then this file resides in your home directory as mercurial.ini. After this setting change you will be able to use the hg convertutility.

如果你在 Windows 上使用TortoiseHg,那么这个文件作为mercurial.ini. 在此设置更改后,您将能够使用该hg convert实用程序。

回答by VonC

By using the Mercurial Convert extension

通过使用Mercurial Convert 扩展

Add the following lines to your .hgrcor to enable the extension :

将以下行添加到您的.hgrc或 以启用扩展:

[extensions]
hgext.convert=

And typing a

并输入一个

cd src
hg convert --datesort . dst

(even though it can lead to some issues...)

(即使它会导致一些问题......)

Note:: metrixreports that this might not work:

注意:: metrix报告这可能不起作用:

     hg convert --datesort src dst

Note:there happens to be a bug with hg convertif you perform this command from a directory other than the source directory.
You will get the following error:

注意:hg convert如果您从源目录以外的目录执行此命令,则会出现错误。
您将收到以下错误:

abort: cannot read tags from git-repo4/.git

Confirmed with git 1.7.9 and Mercurial 2.6.2 on Windows XP

在 Windows XP 上使用 git 1.7.9 和 Mercurial 2.6.2 确认

回答by vdboor

You may want to look at the http://hg-git.github.com/utility: a Git plugin for Mercurial

您可能想查看http://hg-git.github.com/实用程序:Mercurial 的 Git 插件

This plugin is originally developped by the guys of GitHub, and allows the convert from git<->mercurial losslessly. In theory, you could even be able to clone the hg repository.

这个插件最初是由 GitHub 的家伙开发的,允许无损地从 git<->mercurial 转换。理论上,您甚至可以克隆 hg 存储库。

回答by Bombe

Distributed revision control with Mercurialstates:

Mercurial 的分布式修订控制声明:

The revision control tools supported by convert are as follows:

  • Subversion
  • CVS
  • Git
  • Darcs

convert支持的版本控制工具如下:

  • 颠覆
  • CVS
  • 吉特
  • 达克斯

So maybe you don't need any additional tool?

所以也许你不需要任何额外的工具?

回答by Luke Francl

The convert extension may work for you, but if it doesn't, you might want to check out tailorwhich is a general purpose tool for converting among the various distributed SCMs.

convert 扩展可能适合您,但如果不适合,您可能需要查看定制,这是一种用于在各种分布式 SCM 之间进行转换的通用工具。

回答by Jay Atkinson

You could just not convert it at all. Just use the Hg-Gitplugin! No one will know the difference.

你根本不能转换它。只需使用Hg-Git插件!没有人会知道其中的区别。

回答by FelipeC

New player in town: git-remote-hg. It provides native bridging support in git.

镇上的新玩家:git-remote-hg。它在 git 中提供本机桥接支持。

Just:

只是:

hg init ../hgrepo
git push hg::$PWD/../hgrepo

回答by stenci

In the Gitfolder with all my Git repositories I created the Git2Hg.cmdfile with the following content:

Git包含我所有 Git 存储库的文件夹中,我创建了Git2Hg.cmd包含以下内容的文件:

set PATH=%PATH%;C:\Program Files\TortoiseHg
set PATH=%PATH%;C:\Program Files\Git\bin
hg convert %1

Now I can convert a Git repository to Hg by typing this in a CMD:

现在我可以通过在 CMD 中输入以下内容将 Git 存储库转换为 Hg:

Git2Hg "Folder Name"

回答by dilshad

Hg-Git Plugin or if u use for windows or migration from one to another visit here 2[Windows GIT]

Hg-Git 插件或者如果你用于 Windows 或从一个迁移到另一个访问这里2[Windows GIT]