Next: , Previous: , Up: Miscellaneous   [Contents][Index]

8.6 Sparse checkouts

Sparse checkouts provide a way to restrict the working tree to a subset of directories. See the git-sparse-checkout(1) manpage.

Warning: Git introduced the git sparse-checkout command in version 2.25 and still advertises it as experimental and subject to change. Magit’s interface should be considered the same. In particular, if Git introduces a backward incompatible change, Magit’s sparse checkout functionality may be updated in a way that requires a more recent Git version.

> (magit-sparse-checkout)

This transient prefix command binds the following suffix commands and displays them in a temporary buffer until a suffix is invoked.

> e (magit-sparse-checkout-enable)

This command initializes a sparse checkout that includes only the files in the top-level directory.

Note that magit-sparse-checkout-set and magit-sparse-checkout-add automatically initialize a sparse checkout if necessary. However, you may want to call magit-sparse-checkout-enable explicitly to re-initialize a sparse checkout after calling magit-sparse-checkout-disable, to pass additional arguments to git sparse-checkout init, or to execute the initialization asynchronously.

> s (magit-sparse-checkout-set)

This command takes a list of directories and configures the sparse checkout to include only files in those subdirectories. Any previously included directories are excluded unless they are in the provided list of directories.

> a (magit-sparse-checkout-add)

This command is like magit-sparse-checkout-set, but instead adds the specified list of directories to the set of directories that is already included in the sparse checkout.

> r (magit-sparse-checkout-reapply)

This command applies the currently configured sparse checkout patterns to the working tree. This is useful to call if excluded files have been checked out after operations such as merging or rebasing.

> d (magit-sparse-checkout-disable)

This command restores the full checkout. To return to the previous sparse checkout, call magit-sparse-checkout-enable.

A sparse checkout can also be initiated when cloning a repository by using the magit-clone-sparse command in the magit-clone transient (see Cloning Repository).

If you want the status buffer to indicate when a sparse checkout is enabled, add the function magit-sparse-checkout-insert-header to magit-status-headers-hook.

Next: , Previous: , Up: Miscellaneous   [Contents][Index]