Migrating from Mercurial to Git

耗尽温柔 提交于 2019-12-07 08:52:27

问题


I know this question asked before several times and marked "possible duplicate", but none of them seems working correct. I tried fast-export and it gives error. Could anyone help How to migrate from Mercurial to Git? I need the history. It would be appreciated if it is listed step by step.

UPDATE:

I tried fast export:

cd ~
git clone git://repo.or.cz/fast-export.git
git init git_repo
cd git_repo
~/fast-export/hg-fast-export.sh -r /path/to/old/mercurial_repo **[I get error in this line]**
git checkout HEAD

this gives error:

..... hg-fast-export.sh: line 79: python: command not found

Thanks for the help!


回答1:


  1. Add hg-git to Mercurial
  2. Push hg-repo to git-target

Step-by-step Guide

A Clone Hg-Git Extension from it's repository into some local PATH\TO\HG-GIT

B Enable extension in (global mercurial.ini or repository's-specific .hgrc)

[extensions]
bookmarks = 
...
hggit = PATH\TO\HG-GIT

bookmark was added long time ago, when this extension wasn't part of TortoiseHG|Mercurial, not sure about today's configuration

C Create new Git-repository with read|write access to it (or remeber existing?!)

D Add Git-repo from p. C into [paths] section of .hgrc for Mercurial repository, which you want to export in Git under any name. Sample for my local Mercurial repository, which have Git-mirror on Github

[paths]
default = git+ssh://git@github.com/lazybadger/Fiver-l10n.git

E After it you can use Git-repository as usual remote repository in Mercurial and, as fist operation (for created empty Git-repository) you have to push to your new remote

F Check existence of Git-repository with full history from Mercurial mirrored into it after push

G Use Git-repository by usual way

Sources, used in this guide

  • Local Mercurial repository of WP-theme with very easy linear history

  • Git-mirror of this repo on Github



来源:https://stackoverflow.com/questions/17970341/migrating-from-mercurial-to-git

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!