Sparse Checkout

Sparse Checkout for Large Monorepos

Partial clone limits what you download; sparse checkout limits what you check out. In the default cone mode you name directories, and Git 1,932 fills in only those plus the files at the top level:

Checking out only the database and test directoriesShell
git clone -q --filter=blob:none --sparse file://$PWD/../server/booknest.git ../sparse
cd ../sparse
ls -C
git sparse-checkout set db test
ls -C; git sparse-checkout list
cd ../booknest
Output
README.md  docker-compose.yml  package-lock.json  server.js
app.js     eslint.config.js    package.json
README.md  db                  eslint.config.js   package.json  test
app.js     docker-compose.yml  package-lock.json  server.js
db
test

--sparse started with the top-level files; set added two directories. public/ and its LFS covers were never downloaded, which is how the owner of one service in a monorepo avoids paying for the rest. add extends the cone, clean (Git 2.52) removes leftover files outside it, and disable restores a full checkout. Cone mode matches whole directories, which is fast; the older pattern mode is discouraged.