Skip to content

Instantly share code, notes, and snippets.

@tokisakiyuu
Created September 28, 2024 12:39
Show Gist options
  • Save tokisakiyuu/bacfc9e53b40007720ead75aa9b98721 to your computer and use it in GitHub Desktop.
Save tokisakiyuu/bacfc9e53b40007720ead75aa9b98721 to your computer and use it in GitHub Desktop.
Merge multiple repos into one monorepo (keep commits history)

Steps

Create Root

mkdir scribo-monorepo
cd scribo-monorepo

Define the workspace

create package.json if you are using yarn:

{
  "private": true,
  "workspaces": ["repo1", "repo2", "packages/*"]
}

create pnpm-workspace.yaml if you are using pnpm:

packages:
  - 'repo1'
  - 'repo2'
  - 'packages/*'

Initialization Git repo

git init
git add .
git commit -m "init"

Import Git Repos (keep commit history)

# git subtree add -P <dir> <repo> <rev>
git subtree add -P "repo1" https://github.com/tokisakiyuu/repo1.git main
git subtree add -P "repo2" https://github.com/tokisakiyuu/repo2.git master
# ...

Done

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