git clone-lean

Clone as lean as possible

Git alias:

clone-lean = clone --depth 1 --filter=combine:blob:none+tree:0 --no-checkout


git clone-lean

This alias skips fetching unneeded objects from the server.

This is good to checkout just one subdirectory.

Command breakdown:

This uses –filter=tree:0 added in Git 2.20 and –filter=combine composite filter added in Git 2.24.

The server should be configured with:

git config --local uploadpack.allowfilter 1
git config --local uploadpack.allowanysha1inwant 1

An extension was made to the Git remote protocol to support this feature in v2.19.0 and actually skip fetching unneeded objects. There was server support then, but it can be locally tested.