I have four separate projects. They have their own git repository. and the same name of branches for all projects.
/project/
/project/projA/
/project/projA/.git/
/project/projB/
/project/projB/.git/
/project/projC/
/project/projC/.git/
/project/projD/
/project/projD/.git/
All git repositories have the same name of branches, and of course their own master branch.
Question
I would like to merge all projects into one like so:
/Project/.git/
/project/projA/
/project/projB/
/project/projC/
/project/projD/
But
i want to keep the history of all branches.
ps -> i have the same name of branches for all repo.
for exemple: a branche name used for all four project: V6-004
Details
I tried submodule and subtree but the both doesn't solve the issue.
I tried also this.
$ mkdir new_parent_project
$ cd new_parent_project
$ git init
# Now we need to create the initial commit. This is essential.
$ touch README.md
$ git add README.md
$ git commit -am "initial commit"
after
# merge project ProjA into subdirectory ProjA
$ git remote add -f ProjA http://GitUrl
$ git merge -s ours --no-commit ProjA/V6-006
$ git read-tree --prefix=ProjA/ -u ProjA/V6-006
$ git commit -m "merging ProjA into subdir: ProjA"
after
# merge project ProjB into subdirectory ProjB
$ git remote add -f ProjB http://GitUrl
$ git merge -s ours --no-commit ProjB/V6-006
$ git read-tree --prefix=ProjB/ -u ProjB/V6-006
$ git commit -m "merging ProjB into subdir: ProjB"
but
the projects are merged but i have only the history of V6-006. but i don't have history for the others branches.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…