I need to get contents of two repo from say 'modA' and 'modB' into a single directory 'mods' in repo main.
main
-- mods
------ modAfiles
-------modBfiles
There is no straight forward way to do this with git so I am creating a third repo that joins these repos. The contents of these mods repos are guaranteed to not conflict each other. So no need to worry about conflicts.
A sample test case.
for repo in main modA modB ; do
git init $repo
echo "test $repo" > "$repo/test$repo"
cd $repo
git add "test$repo"
git config user.name "$repo test"
git config user.email "$repo@test.test"
git commit -m 'Initial commit'
cd ..
done
Now to set up the fused repo.
git init fusion
cd fusion
git remote add modA ../modA/.git
git remote add modB ../modB/.git
git config user.name "fusion test"
git config user.email "fusion@test.test"
git fetch --all
git checkout -b modB_master modB/master
git checkout -b modA_master modA/master
git checkout -b merge_master
git merge modB_master -m "Fuse modA and modB"
ls
Now the problem is with adding this fused repo to the main repo. If either 'modA' or 'modB' updates I can just delete the 'merge_master' branch of 'fusion' and create it again.
I don't care about the history of the merges. I merely want to join these repos. I also dont need to make changes from 'fusion' or 'main' repo. With subtree I added the 'fusion' repo to 'main' repo. But whenever I change the 'merge_master' it gets force update and also all the commits are shown in the 'main' repo.
How can I add the fusion repo to main without polluting the main repo. Should I be using submodules instead? Also the mods repo get frequently updated. (the creation merge_master will be automated ). Or is there a better way of doing this?