kinu-garage / hut_10sqft

Computer setup tools for my own environment, and public discussion place holder.
Apache License 2.0
2 stars 1 forks source link

Frequently revisiting "Import git commit history for a sub folder from another repo" #595

Open 130s opened 2 years ago

130s commented 2 years ago

I've done it a few times and I always forgot how to do that...Needs to be taken as a note.

130s commented 2 years ago

For a repo that is less critical to maintain the commit history cleanest and preserve original commits, consolidation (medium.com) might be fine.

echo "Create an empty repo locally, CD into a new cosolidated repo." && mkdir -p org/suborg/reponame && cd org/suborg/reponame && git remote add origin git@gitlab.com:top-group/org/suborg/reponame.git

echo "Consolidate repos."
git remote add -f reponame https://gitlab.com/top-group/reponame/reponame
git merge --allow-unrelated-histories reponame/develop

git remote add -f reponame_ai https://gitlab.com/top-group/reponame/reponame_ai
git merge --allow-unrelated-histories reponame_ai/develop

git remote add -f reponame_tools https://gitlab.com/top-group/reponame/reponame_tools
git merge --allow-unrelated-histories reponame_tools/develop

echo "Top level dirs from each repo remain in the top level dir."