changing the sparse-checkout patterns in cone mode, Git will inspect each
tracked directory that is not within the sparse-checkout cone to see if it
contains any untracked files. If all of those files are ignored due to the
`.gitignore` patterns, then the directory will be deleted. If any of the
untracked files within that directory is not ignored, then no deletions will
occur within that directory and a warning message will appear. If these files
are important, then reset your sparse-checkout definition so they are included,
use `git add` and `git commit` to store them, then remove any remaining files
manually to ensure Git can behave optimally.
See also the "Internals -- Cone Pattern Set" section to learn how the
directories are transformed under the hood into a subset of the
Full Pattern Set of sparse-checkout.
INTERNALS -- FULL PATTERN SET
-----------------------------
The full pattern set allows for arbitrary pattern matches and complicated
inclusion/exclusion rules. These can result in O(N*M) pattern matches when
updating the index, where N is the number of patterns and M is the number
of paths in the index. To combat this performance issue, a more restricted
pattern set is allowed when `core.sparseCheckoutCone` is enabled.
The sparse-checkout file uses the same syntax as `.gitignore` files;
see linkgit:gitignore[5] for details. Here, though, the patterns are
usually being used to select which files to include rather than which
files to exclude. (However, it can get a bit confusing since
gitignore-style patterns have negations defined by patterns which
begin with a '!', so you can also select files to _not_ include.)
For example, to select everything, and then to remove the file
`unwanted` (so that every file will appear in your working tree except
the file named `unwanted`):
git sparse-checkout set --no-cone '/*' '!unwanted'
These patterns are just placed into the
`$GIT_DIR/info/sparse-checkout` as-is, so the contents of that file
at this point would be
----------------
/*
!unwanted
----------------
See also the "Sparse Checkout" section of linkgit:git-read-tree[1] to
learn more about the gitignore-style patterns used in sparse
checkouts.
INTERNALS -- CONE PATTERN SET
-----------------------------
In cone mode, only directories are accepted, but they are translated into
the same gitignore-style patterns used in the full pattern set. We refer
to the particular patterns used in those mode as being of one of two types:
1. *Recursive:* All paths inside a directory are included.
2. *Parent:* All files immediately inside a directory are included.
Since cone mode always includes files at the toplevel, when running
`git sparse-checkout set` with no directories specified, the toplevel
directory is added as a parent pattern. At this point, the
sparse-checkout file contains the following patterns:
----------------
/*
!/*/
----------------
This says "include everything immediately under the toplevel
directory, but nothing at any level below that."
When in cone mode, the `git sparse-checkout set` subcommand takes a
list of directories. The command `git sparse-checkout