Skip to content

Instantly share code, notes, and snippets.

@aSapien
aSapien / monorepo-sparse.md
Last active August 13, 2018 07:26
[Working with a monorepo in isolated subrepos] A way to mimic a multi-repo git environment inside a single monorepo #monorepo #git #trick

Clone a monorepo as isolated subrepos

Motivation & Goal

When working on a monorepo, we often create uncommitted changes in multiple "subrepos", which turns into a mess when preparing a commit, when pulling changes from remote, etc...

Git allows us to create a sparse-clone of the monorepo, containing only the subrepo that we are interested in, yet keeping the integrity and functions of a VCS.

For example, we have a monorepo with the following structure (computer@user:~$ tree monorepo):