git sparse-checkout command for monorepo

We are implementing monorepo internally to let all teams work closely. As there are dependencies between each team’s work, it is important to understand and track the cross-project changes that go into the monorepo. Monorepo is a good practice that brings in better collaboration, but it also introduces some inconveniences.

The biggest complaints I heard is that the monorepo is growing larger everyday, and it takes a good amount of time to clone or checkout. When a team runs a build, they only need to checkout their project in the monorepo instead of the whole repository. The current solution is to add a sparse-check config file in .git. For example:

git config core.sparseCheckout true
echo "myproject/*" >> .git/info/sparse-checkout

Now a new git sparse-checkout command is available, according to this post: Bring your monorepo down to size with sparse-checkout. This should a handy tool for monorepo users.


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s