This checklist helps you merge two storefront apps and their shared component library into one monorepo, so that you keep the Git history of all three repositories and the releases of both apps keep working. It is written for tech leads and frontend engineers who plan such a merge. The examples use Git 2.56.1, git-filter-repo 2.47.0, pnpm 12.25.1, Turborepo 2.11.13 and Storybook 11.0.0, with Azure Pipelines for CI. These are the current versions on 1 December 2026.
The target layout has one folder per app and one folder for the library:
apps/brand-a # storefront of brand A
apps/brand-b # storefront of brand B
packages/ui # component library with Storybook
Once the apps share a repository, they can also share tooling such as telemetry, and OpenTelemetry in a Turborepo monorepo shows an example.
Sanity checks before the merge
Run these checks on all three repositories before you move a single file, and write down the answer to each check and who owns it. Start the merge once every check has an answer.
| Check | What to compare |
|---|---|
| Dependency versions | React, Next.js, TypeScript, ESLint and Storybook in each package.json |
| Node.js version | engines.node, .nvmrc and the Node.js version in each pipeline |
| Build and test commands | The names of the build, lint, test and dev scripts, and what they run |
| Environment variables | The variables each app needs at build time and at runtime |
| CI/CD pipelines | Pipeline files, variable groups and service connections per repository |
| Deploy targets | Where each app runs, for example a container image and a cluster namespace |
| Ownership | Who reviews which folders today |
| Release process | Tag names, version numbers and release notes per repository |
| Storybook | Version, addons, build command and where the static build is hosted |
| Open work | Open branches and pull requests in each repository |
A short script shows the version differences side by side when you run it in a folder with clones of the three repositories:
// compare-versions.mjs
import { readFileSync } from 'node:fs'
const repos = ['brand-a', 'brand-b', 'ui']
const names = ['react', 'react-dom', 'next', 'typescript', 'eslint', 'storybook']
for (const name of names) {
const versions = repos.map((repo) => {
const pkg = JSON.parse(readFileSync(`${repo}/package.json`, 'utf8'))
return pkg.dependencies?.[name] ?? pkg.devDependencies?.[name] ?? pkg.peerDependencies?.[name] ?? '-'
})
console.log(name.padEnd(12), versions.join(' '))
}
Pick one version per dependency for the monorepo, and if an app must keep its own version for a while, write down why. Check the peerDependencies of the component library against the React version of both apps.
Check the tags as well, because if both apps have a tag v1.4.0, the tags clash in one repository. Plan a prefix per app before the merge.
Merge with the history preserved
There are three common ways to keep the history, and they differ in what happens to old commits.
| Method | Paths in old commits | Commit hashes | History of one file |
|---|---|---|---|
| git-filter-repo, then merge | Rewritten to the new folder | New | git log -- <new path> |
| Move commit, then merge | Old paths | Kept | git log --follow -- <new path> |
git subtree add |
Old paths | Kept | git blame shows old commits, git log stops at the import |
git-filter-repo and an unrelated-histories merge
git-filter-repo, which you install as described in its INSTALL file, rewrites a repository so that every commit has its files in a subfolder.
Start with a fresh clone of each repository, because git-filter-repo refuses to run on a clone that is not fresh. Do not override this check with --force, and for a local copy, clone with git clone --no-local.
git clone <brand-a-url> brand-a
cd brand-a
git filter-repo --to-subdirectory-filter apps/brand-a --tag-rename '':'brand-a-'
cd ..
Repeat this for brand-b with apps/brand-b, and for the library with packages/ui and the prefix ui-.
--to-subdirectory-filter apps/brand-amakes every commit look as if the project always lived inapps/brand-a.--tag-rename '':'brand-a-'adds a prefix to every tag, sov1.4.0becomesbrand-a-v1.4.0.- git-filter-repo turns the remote-tracking branches of the clone into local branches, so open feature branches are rewritten as well.
Then merge the rewritten repositories into a new repository:
git init -b main monorepo
cd monorepo
git commit --allow-empty -m "Start monorepo"
git remote add brand-a ../brand-a
git fetch --tags brand-a
git merge --allow-unrelated-histories -m "Import brand-a storefront" brand-a/main
git remote remove brand-a
Repeat the last four commands for brand-b and ui. By default, git merge refuses to merge histories without a common ancestor, and --allow-unrelated-histories allows it. git fetch --tags brings in all tags with their new prefix.
Root files of each repository, such as .gitignore, .nvmrc and pipeline files, now sit in the app folder, so decide which of them move back to the root of the monorepo.
All commit hashes change, and links to old commits in tickets and pull requests still point to the old repositories.
The other two methods
With the move commit method, you add one commit to each old repository that moves all files into the target folder with git mv, and then you merge with --allow-unrelated-histories as above. The hashes stay the same, but old commits keep their old paths, so you need git log --follow to see the history of one file.
git subtree add --prefix=packages/ui <ui-url> main imports a repository into a folder in one step and keeps the full history, unless you add --squash. git subtree lives in the contrib folder of Git, not in the core commands.
Rehearse, then cut over
Put the merge steps in a script, run it on fresh clones and check the result:
git log --oneline -- apps/brand-a | tail -n 3
git tag --list 'brand-a-*'
pnpm install
pnpm exec turbo run lint test build
Repeat this until every app builds and every test passes. On the day of the cutover, ask everyone to merge or push their open pull requests first, then run the script one more time on fresh clones and push the result.
After the cutover, stop new work in the old repositories. In Azure Repos, you can do this with the Disable Repository setting, which blocks access, builds and pull requests.
Workspaces and Turborepo
With pnpm, you tell the package manager where the packages are in pnpm-workspace.yaml:
packages:
- apps/*
- packages/*
With npm, add "workspaces": ["apps/*", "packages/*"] to the root package.json instead. Either way, Turborepo does not support nested packages, such as a package inside apps/brand-a/tools.
The root package.json runs all tasks through Turborepo:
{
"private": true,
"scripts": {
"build": "turbo run build",
"dev": "turbo run dev",
"lint": "turbo run lint",
"test": "turbo run test"
},
"devDependencies": {
"turbo": "2.11.13"
},
"devEngines": {
"packageManager": {
"name": "pnpm",
"version": "12.25.1"
}
}
}
Each app depends on the library through the workspace: with pnpm, add "@repo/ui": "workspace:*" to the dependencies of the app, and with npm, use "*" as the version.
Then add turbo.json to the root:
{
"$schema": "https://turborepo.dev/schema.json",
"tasks": {
"build": {
"dependsOn": ["^build"],
"outputs": [".next/**", "!.next/cache/**", "dist/**"]
},
"build-storybook": {
"dependsOn": ["^build"],
"outputs": ["storybook-static/**"]
},
"lint": {},
"test": {
"dependsOn": ["^build"]
},
"dev": {
"cache": false,
"persistent": true
}
}
}
In the library, give the Storybook build a fixed output folder with "build-storybook": "storybook build -o storybook-static", so that the cache knows which folder to restore.
Turborepo runs tasks in strict environment mode by default, so a task only gets the variables you list, plus a few built-in ones such as PATH. Add the build-time variables from your sanity checks to env in turbo.json. The OpenTelemetry post explains env and passThroughEnv with an example.
To keep versions aligned after the merge, the Turborepo docs list syncpack, manypkg and sherif, and pnpm catalogs are another option.
CI per app with path filters
Give each app its own pipeline with a path filter, so that the pipeline only starts when a file changes that can affect that app, including the shared packages and the root files.
# apps/brand-a/azure-pipelines.yml
trigger:
branches:
include:
- main
paths:
include:
- apps/brand-a
- packages
- package.json
- pnpm-lock.yaml
- pnpm-workspace.yaml
- turbo.json
pool:
vmImage: ubuntu-latest
steps:
- checkout: self
- script: npm install -g pnpm@12.25.1
displayName: Install pnpm
- script: pnpm install --frozen-lockfile
displayName: Install dependencies
- script: pnpm exec turbo run lint test build --filter=brand-a...
displayName: Lint, test and build brand-a
- Paths are relative to the root of the repository, and they are case-sensitive.
- If you exclude a folder, you can only include a deeper folder of it again.
--filter=brand-a...selects the package namedbrand-aand all packages it depends on, so a change in the library is tested together with the app.- Keep the deploy stages of each app as they were, because only the trigger and the build command change.
Pull request builds work differently in Azure Repos, where you cannot set a pr: trigger in the YAML file. Add a Build validation branch policy on main instead, and set its path filter. Branch policy path filters use their own syntax, where a path starts with / or a wildcard, ; separates paths and ! excludes a path:
/apps/brand-a/*;/packages/*;/package.json;/pnpm-lock.yaml;/pnpm-workspace.yaml;/turbo.json
Ownership and team rules after the merge
In one repository, ownership follows folders, so in Azure Repos you add an Automatically included reviewers policy per folder. For example, use the path /packages/ui/* for the library owners and /apps/brand-a/* for the team of brand A, and mark the policy as Required if their approval must block the pull request.
On GitHub, a CODEOWNERS file in .github/, the root or docs/ does the same, and the last matching pattern wins. Turn on Require review from Code Owners in the branch protection rule.
Agree on team rules and write them down:
- Keep pull requests small, and change one app or one package per pull request where you can.
- Merge a library change in its own pull request before an app uses it.
- Write release notes per app, with the prefixed tags.
- Update the README and the docs: where each app lives, how to run one app with
pnpm exec turbo run dev --filter=brand-a, and how a release works.
After the first release from the monorepo, check each app again and compare the results with the last release from the old repository: lint, build, deployment, automated QA tests, tag manager and third-party scripts, page metadata, API calls and Core Web Vitals.
In practice
A multi-brand consumer goods company that sells direct to consumers had two brand storefronts and a component library in separate repositories, and each brand built the same components again. The case study has the full context.
We led the frontend architecture and the frontend chapter, and in June 2023 we wrote a report on a move to a monorepo. Together with the team, we then made a checklist of sanity checks, and the merge would only go ahead once the checks covered all use cases. The plan for the cutover asked everyone to merge or push their open pull requests first, and the merge steps were rehearsed. A developer in the team did the merge in July 2023, with our help and review. We also wrote the release notes for the monorepo and its pipelines and updated the documentation.
The component library was built in Storybook, based on atomic design, and one brand’s redesign was built with it. The migration to the Next.js App Router waited for the merge and its checks and started after the merge. In December 2023 the documentation was updated, and the team got rules for small pull requests and for reviews.
Checklist
- Compare dependency versions, the Node.js version and script names in all repositories.
- List environment variables, pipelines and deploy targets per app.
- Plan tag prefixes so that release tags do not clash.
- Run git-filter-repo on fresh clones, without
--force. - Merge into a new repository with
--allow-unrelated-histories. - Rehearse the script until every app builds and every test passes.
- Ask everyone to merge or push open work before the cutover.
- Disable the old repositories after the cutover.
- Set up workspaces and
turbo.json, with a fixed output folder for Storybook. - Add path filters to each app pipeline and to the Build validation policy.
- Add required reviewers per folder.
- Agree on small pull requests and reviews, and update the release notes and docs.
To have your repositories reviewed before a merge like this, see the design system and monorepo audit or contact us.
Sources
- Git: git-merge
- Git: git-fetch
- Git: git-log
- Git: git-subtree
- git-filter-repo: manual
- git-filter-repo: INSTALL
- Turborepo: Structuring a repository
- Turborepo: Managing dependencies
- Turborepo: run reference
- pnpm: Workspace
- Storybook: CLI options
- Microsoft Learn: Azure Repos Git triggers
- Microsoft Learn: Branch policies and settings
- Microsoft Learn: Repository settings and policies
- GitHub Docs: About code owners