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 pull
ing 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?
All your branches and tags should be on your new Git server in a nice, clean import. Since Mercurial and Git have fairly similar models for representing versions, and since Git is a bit more flexible, converting a repository from Mercurial to Git is fairly straightforward, using a tool called "hg-fast-export", which you’ll need a copy of:
Mercurial has lost the popularity war with Git and BitBucket claims that less than 1% of new repositories on their service use Mercurial. The surprising thing is that BitBucket announced that they are deleting Mercurial repositories from their service as of June 2020.
Mercurial is a distributed source control management tool similar to, but less popular than Git. This move isn’t surprising. Mercurial has lost the popularity war with Git and BitBucket claims that less than 1% of new repositories on their service use Mercurial.
In August 2019, BitBucket – a popular cloud source code hosting and project management service run by Atlassian – announced that it was dropping support for Mercurial repositories. Mercurial is a distributed source control management tool similar to, but less popular than Git. This move isn’t surprising.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With