1 # How to convert Mercurial Repositories with subrepos
5 hg-fast-export supports migrating mercurial subrepositories in the
6 repository being converted into git submodules in the converted repository.
8 Git submodules must be git repositories while mercurial's subrepositories can
9 be git, mercurial or subversion repositories. hg-fast-export will handle any
10 git subrepositories automatically, any other kinds must first be converted
11 to git repositories. Currently hg-fast-export does not support the conversion
12 of subversion subrepositories. The rest of this page covers the conversion of
13 mercurial subrepositories which require some manual steps:
15 The first step for mercurial subrepositories involves converting the
16 subrepository into a git repository using hg-fast-export. When all
17 subrepositories have been converted, a mapping file that maps the mercurial
18 subrepository path to a converted git submodule path must be created. The
19 format for this file is:
21 "<mercurial subrepo path>"="<git submodule path>"
22 "<mercurial subrepo path2>"="<git submodule path2>"
25 The path of this mapping file is then provided with the --subrepo-map
30 Example mercurial repo folder structure (~/mercurial):
36 Create an empty new folder where all the converted git modules will be imported:
40 ### Convert all submodules to git:
44 hg-fast-export.sh -r ~/mercurial/subrepo1
49 hg-fast-export.sh -r ~/mercurial/subrepo2
51 ### Create mapping file
53 cat > submodule-mappings << EOF
54 "subrepo/subrepo1"="../submodule1"
55 "subrepo/subrepo2"="../submodule2"
58 ### Convert main repository
63 hg-fast-export.sh -r ~/mercurial --subrepo-map=../submodule-mappings
66 The resulting repository will now contain the subrepo/subrepo1 and
67 subrepo/subrepo1 submodules. The created .gitmodules file will look
70 [submodule "subrepo/subrepo1"]
71 path = subrepo/subrepo1
73 [submodule "subrepo/subrepo2"]
74 path = subrepo/subrepo2