Skip to content

Instantly share code, notes, and snippets.

@JalilArfaoui
Created February 5, 2024 23:35
Show Gist options
  • Save JalilArfaoui/99eece7ab1ce0aaffb32929744e7fd8f to your computer and use it in GitHub Desktop.
Save JalilArfaoui/99eece7ab1ce0aaffb32929744e7fd8f to your computer and use it in GitHub Desktop.
Merge multiple git repos with history into one monorepo

1️⃣ Create an empty git repository named « Monorepo ».

2️⃣ For each existing "project_x" repository, move all files and folders (except .git) into a target path in the new monorepo, and then :

git commit -m "move all project_x files into /project-x"
git remote add monorepo MONOREPO_URL
git fetch monorepo
git merge monorepo/main --allow-unrelated-histories -m "merge project_x into monorepo"
git push mono   

🔄 Repeat for each each existing repository !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment