Interview Prep/Git & GitHub/Rebase, Cherry-pick and History Rewriting

One service in the monorepo must become its own repo, with its history.

AdvancedScenarioRebase, Cherry-pick and History Rewriting
Answer

Situation read → You need only the commits that touched services/billing, with paths moved to the root.

What I'd do →

  1. Fresh clone: git clone --no-local monorepo billing && cd billing.
  2. git filter-repo --subdirectory-filter services/billing.
  3. Add the new remote and push all branches and tags.
  4. In the monorepo, remove the directory and point to the new repo (or add it as a submodule or package dependency).

Why → filter-repo rewrites quickly and keeps only relevant history. Never run it on your working clone.

Interview tip → Plan CI, issue transfer, and CODEOWNERS for the new repo as part of the split.

All Git & GitHub questions Roadmap: Git & GitHub

More on Rebase, Cherry-pick and History Rewriting