git remote add project-b <project-b git remote>
git fetch project-b
git branch branch-from-project-b project-b/main
git checkout branch-from-project-b
mkdir project-b
git ls-tree -z --name-only HEAD | xargs -0 -I {} git mv {} project-b/
git commit -m "Merge project-b repository as subdirectory project-b"
git checkout main
git pull
git checkout -b merge-project-b-as-subdirectory
git merge --allow-unrelated-histories branch-from-project-b
git push
Merge Git Repository as Subdirectory
cpcwood | Last updated:
Create git branch in project-a with project-b added in directory ./project-b
.
Git history is retained.