如何将 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
How do I convert a git repository to mercurial?
提问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 convert
utility isn't on by default after installation. In order to set it as such add the following to your .hgrc
file.
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 convert
utility.
如果你在 Windows 上使用TortoiseHg,那么这个文件作为mercurial.ini
. 在此设置更改后,您将能够使用该hg convert
实用程序。
回答by VonC
By using the Mercurial Convert extension
Add the following lines to your
.hgrc
or 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 convert
if 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:
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
回答by Jay Atkinson
回答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 Git
folder with all my Git repositories I created the Git2Hg.cmd
file 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"