21

I have a very old project that includes the source from another project directly, instead of linking it as a library. Back in the bad days, when I was keeping everything in CVS, I had the external code on a vendor branch and did periodic imports. Now that my project is in git it would make more sense to include the external project as a submodule. But, there's a problem: the external project has migrated to Mercurial. I've found the git-hg and hg-git projects, but I'm not sure if either one handles submodules properly.

Is there a way to create a git submodule that points to an Hg repo instead of a git repo?

Martin Geisler
  • 72,968
  • 25
  • 171
  • 229
Brandon Fosdick
  • 15,673
  • 4
  • 21
  • 20

1 Answers1

12

Since the hg-git does mention that submodules are not supported yet, that leaves only a manual option:

  • setup a Git repository somewhere that you have push access to,
  • add it as a Git remote and then
  • run hg gpush from within your project.

For example:

$ cd hg-git # (an Hg repository)
$ hg gremote add origin git@github.com/schacon/hg-git.git
$ hg gpush

That Git repo will represent your submodule, but if you modify and push that submodule, you will still have to pull from that Git repo to the actual Hg repo.

Other great git-hg commands are listed in this "rosetta stone".

0xC0000022L
  • 20,597
  • 9
  • 86
  • 152
VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
  • 1
    There's a typo in the example. "$ hg push" should be "$ hg gpush" as mentioned in the description above. Except that, @VonC's answer was very helpful for me. Thanks! :-) –  Aug 05 '09 at 23:51
  • 1
    This example is confusing with its naming. What's the main repository directory and what's the submodule/subrepo dir? – einpoklum Jul 27 '16 at 23:37
  • @einpoklum from what I can read from this 7 years old question, the submodule is the external repo which has migrated to mercurial. The goal is to push from your local mercurial clone to the remote Git repo, which can then be referenced as submodule by any Git parent repo. – VonC Jul 28 '16 at 05:58