Gili
Gili

Reputation: 90101

Contributing patches from Mercurial to Git?

I'd like to fork a Git repository, convert it to Mercurial, and contribute my changes back to the original Git repository when I'm done. I am more concerned with a safe and stable conversion process than its convenience. I will be pulling changes from Git into Mercurial on a regular basis but rarely contributing any changes back.

I'm not comfortable using hg-git because many of the bugs reported against the project have gone unanswered for years. I suspect it's safer to use hg convert to convert Git to Hg than using hg-git.

My question is: say I've already converted the repository to Mercurial and made some changes, how do I contribute these changes back to the official repository? I'd like to contribute my changes back to the official Git repository without losing any history information (that is, I don't want to fold multiple changesets into a one).

What is the easiest and safest way to do this?

Upvotes: 8

Views: 3160

Answers (1)

VonC
VonC

Reputation: 1326992

You can try and export your Mercurial commits as patches:

hg export --git -r 1 >patch.diff

This .diff file should be recognized by Git and could be added to the git repo with git apply.
(This was suggested in "Convert a Mercurial Repository to Git", where the more up-to-date script hg-fast-export was also mentioned)

The --git option of hg export will make sure you generate diffs in the git extended diff format. See hg help diffs for more information.

Upvotes: 9

Related Questions