Skip to content

Instantly share code, notes, and snippets.

View aod7br's full-sized avatar

Andre Dias aod7br

  • EnCirca
  • Rio de Janeiro
  • 23:20 (UTC -03:00)
  • LinkedIn in/andre-dias
View GitHub Profile
@acg
acg / combine-repos-into-mono-repo.md
Created July 10, 2023 17:31
How to combine two git repos into a monorepo without `git merge`

Use Case

Suppose you have local checkouts of two git repositories, a and b. You'd like to combine them into a new git repo c ("the monorepo"). More specifically, you'd like to:

  1. Preserve the combined commit history.
  2. Keep the commits from a and b ordered chronologically in c, interleaving as necessary.
  3. Avoid new merge commits, because you're a rebase-only freak like me. Most answers on the internet use git merge.
  4. Ignore all branches of a and b other than master. It's possible to port them over, but would significantly complicate these instructions. So for now that's an exercise left for the reader.

Preliminaries