Unlock Faster Clones: How Git 2.25’s Partial Clone and Sparse Checkout Transform Large Repos
Git 2.25.0 introduces experimental partial clone and sparse checkout features that let developers fetch only needed objects and skip unnecessary files during checkout, dramatically reducing network and storage costs for massive repositories while simplifying configuration through the new git sparse-checkout command.
Git 2.25.0 was released, and contributor Taylor Blau highlighted two major features: partial clone and sparse checkout.
Partial clone allows a client to fetch only a subset of objects from a repository, reducing network transfer and local storage for very large projects. The client must tell the server which objects it needs, and the server must respond with only those objects. The feature is still experimental, with early support in Gitee.
To avoid checkout conflicts when objects are missing, Git can skip the checkout step, which is implemented by the sparse checkout feature.
Sparse checkout works like a .gitignore list of path patterns that tells Git which files to omit during checkout. Unlike .gitignore, it operates on the working tree rather than the index.
Example of a manual sparse checkout configuration:
$ git clone --filter=blob:none --no-checkout /your/repository/here repo
$ cd repo
$ cat >.git/info/sparse-checkout <<EOF
/*
!/*
EOF
$ git config core.sparseCheckout 1
$ git checkout .Git 2.25 introduces the git sparse-checkout command, simplifying these operations. The command can set, list, enable, or disable sparse checkout without editing .gitignore or .git/info/sparse-checkout manually.
Key commands:
$ git clone --filter=blob:none --sparse /your/repository/here repo
$ git sparse-checkout set /path/to/check/outThe command also supports “cone” mode via git config core.sparseCheckoutCone, allowing stricter pattern matching where a whole subdirectory can be included or excluded without complex .gitignore patterns.
For example, in a large repository with a directory A/B/C that needs full checkout while its ancestors only need enough files to reach it, you can run: $ git sparse-checkout set A/B/C For a full list of changes in Git 2.25, see the following resources:
https://lore.kernel.org/git/[email protected]
https://github.blog/2020-01-13-highlights-from-git-2-25
Signed-in readers can open the original source through BestHub's protected redirect.
This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactand we will review it promptly.
Programmer DD
A tinkering programmer and author of "Spring Cloud Microservices in Action"
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.
