如何将* Mercurial存储库转换为Git ... in * Windows *? [重复]

问题描述 投票:16回答:1

可能重复: Converting a Mercurial (hg) repository to Git on Windows (7)

有一个Mercurial存储库,我想转换为Git,这是我们在工作中使用的。我安装了Mercurial(用于Windows),并且我已经在本地克隆了Hg存储库。我一直试图改变它。

我发现的大多数页面都假设我使用的是Unix / Linux,而最常见的建议hg-fast-export似乎只适用于那些操作系统。我可以访问Git Bash。我已经达到了这个目的(换行包装以便于阅读):

$ ~/codeingit/fast-export/hg-fast-export.sh -r
        ~/codeinmercurial/projectiwanttoconvert

作为回应,我得到:

ImportError:没有名为mercurial的模块

我已经阅读了很多关于此的网页,再次假设我使用的是Unix / Linux并且我已经安装了Mercurial。

是否有人在Windows上成功将Hg存储库转换为Git,并且可以编写分步指南来执行此操作?

git mercurial
1个回答
40
投票

1)Install CygwinBash on Windows 10

Cygwin的

  • 运行setup.exe
  • 选择从Internet安装
  • 在“选择包”对话框中: 单击树顶部的“安装”(“全部”旁边),直到显示“默认” 展开Devel子树:安装git(从Skip更改为版本号) 在Devel子树中:安装mercurial(从Skip更改为版本号) 安装Python子树(从默认更改为安装) 点击下一步
  • 如果提示解决依赖关系,请单击“下一步”
  • 喝杯咖啡,看你最喜欢的电影,或者小睡一会儿

完成Cygwin安装后,打开bash shell以运行以下步骤中指示的命令。 bash的快捷方式称为Cygwin Terminal。

Windows 10

2)安装fast-export

打开终端(bash shell)并安装快速导出:

   https://github.com/frej/fast-export.git

3)初始化新的git repo并迁移mercurial repo

   mkdir new_git_repo
   cd new_git_repo
   git init
   ../fast-export/hg-fast-export.sh -r /path/to/old/mercurial_repo
   git checkout HEAD

潜在的错误

fatal: Invalid raw date "<devnull@localhost> xxx -xxxx" in ident:  <><devnull@localhost> xxx -xxxx

尝试添加“authors.txt”文件,如here所述,包含:

<>=devnull <devnull@localhost>

命令行现在显示为:

../fast-export/hg-fast-export.sh -r /path/to/old/mercurial_repo -A ../fast-export/authors
© www.soinside.com 2019 - 2024. All rights reserved.