Commit ed5336a7 authored by Duy Nguyen's avatar Duy Nguyen Committed by Junio C Hamano

Introduce "sparse checkout"

With skip-worktree bit, you can manually set it to unwanted files,
then remove them: you would have the so-called sparse checkout. The
disadvantages are:

 - Porcelain tools are not aware of this. Everytime you do an
   operation that may update working directory, skip-worktree may be
   cleared out. You have to set them again.

 - You still have to remove skip-worktree'd files manually, which is
   boring and ineffective.

These will be addressed in the following patches. This patch gives an
idea what is "sparse checkout" in Documentation/git-read-tree.txt.
This file is chosen instead of git-checkout.txt because it is quite
technical and user-unfriendly. I'd expect git-checkout.txt to have
something when Porcelain support is done.
Signed-off-by: Duy Nguyen's avatarNguyễn Thái Ngọc Duy <[email protected]>
Signed-off-by: default avatarJunio C Hamano <[email protected]>
parent cb097534
......@@ -360,6 +360,50 @@ middle of doing, and when your working tree is ready (i.e. you
have finished your work-in-progress), attempt the merge again.
Sparse checkout
---------------
"Sparse checkout" allows to sparsely populate working directory.
It uses skip-worktree bit (see linkgit:git-update-index[1]) to tell
Git whether a file on working directory is worth looking at.
"git read-tree" and other merge-based commands ("git merge", "git
checkout"...) can help maintaining skip-worktree bitmap and working
directory update. `$GIT_DIR/info/sparse-checkout` is used to
define the skip-worktree reference bitmap. When "git read-tree" needs
to update working directory, it will reset skip-worktree bit in index
based on this file, which uses the same syntax as .gitignore files.
If an entry matches a pattern in this file, skip-worktree will be
set on that entry. Otherwise, skip-worktree will be unset.
Then it compares the new skip-worktree value with the previous one. If
skip-worktree turns from unset to set, it will add the corresponding
file back. If it turns from set to unset, that file will be removed.
While `$GIT_DIR/info/sparse-checkout` is usually used to specify what
files are in. You can also specify what files are _not_ in, using
negate patterns. For example, to remove file "unwanted":
----------------
*
!unwanted
----------------
Another tricky thing is fully repopulating working directory when you
no longer want sparse checkout. You cannot just disable "sparse
checkout" because skip-worktree are still in the index and you working
directory is still sparsely populated. You should re-populate working
directory with the `$GIT_DIR/info/sparse-checkout` file content as
follows:
----------------
*
----------------
Then you can disable sparse checkout. Sparse checkout support in "git
read-tree" and similar commands is disabled by default.
SEE ALSO
--------
linkgit:git-write-tree[1]; linkgit:git-ls-files[1];
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment