1

How can I move a Mercurial repo into a sub-directory of an existing git repo?

fast-export and other approaches use an empty repo

Co-der
  • 363
  • 1
  • 14
  • Do you want to convert the HG repo to Git? Or do you mean you want to leave it as an HG repo but place it within a git repo's directories? – StayOnTarget Jun 14 '19 at 15:52
  • I want to be completely git and one repo, so I want to import the HG repo contents into a folder within the GIT repo. I don't want to use HG after this is done – Co-der Jun 14 '19 at 16:19
  • This is one approach which should work: https://stackoverflow.com/a/15223912/3195477 – StayOnTarget Jun 14 '19 at 16:30

2 Answers2

0

Short answer

Nohow

Longer answer

Because:

  1. Git from a box can't work with Mercurial repos directly
  2. Repo in folder of a repo is Git's submodules or subtrees (subtree is better - less headache - way)

you have:

  1. Convert Mercurial repo to Git
  2. Use this Git-repo in parent in preferred by you way
Lazy Badger
  • 94,711
  • 9
  • 78
  • 110
0

Expanding a little on my comment:

  1. Use the hg convert feature with the --filemap option to modify the existing HG repo so that the folder structure looks like what you want. For instance, move everything into a subfolder called /from_hg.

  2. Use one of the available tools like hg-git to convert the modified hg repo to a git repo

  3. Merge from the converted git repo into your main git repo. Now you will have subfolder /from_hg in your git repo. Your git repo has two unrelated start points. This is quite similar to Linus Torvald's "coolest merge ever" I think.

This procedure is somewhat similar to https://stackoverflow.com/a/15223912/3195477.

StayOnTarget
  • 11,743
  • 10
  • 52
  • 81