Skip to content

Commit ed5336a

Browse files
pcloudsgitster
authored andcommitted
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: Nguyễn Thái Ngọc Duy <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent cb09753 commit ed5336a

File tree

1 file changed

+44
-0
lines changed

1 file changed

+44
-0
lines changed

Documentation/git-read-tree.txt

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -360,6 +360,50 @@ middle of doing, and when your working tree is ready (i.e. you
360360
have finished your work-in-progress), attempt the merge again.
361361

362362

363+
Sparse checkout
364+
---------------
365+
366+
"Sparse checkout" allows to sparsely populate working directory.
367+
It uses skip-worktree bit (see linkgit:git-update-index[1]) to tell
368+
Git whether a file on working directory is worth looking at.
369+
370+
"git read-tree" and other merge-based commands ("git merge", "git
371+
checkout"...) can help maintaining skip-worktree bitmap and working
372+
directory update. `$GIT_DIR/info/sparse-checkout` is used to
373+
define the skip-worktree reference bitmap. When "git read-tree" needs
374+
to update working directory, it will reset skip-worktree bit in index
375+
based on this file, which uses the same syntax as .gitignore files.
376+
If an entry matches a pattern in this file, skip-worktree will be
377+
set on that entry. Otherwise, skip-worktree will be unset.
378+
379+
Then it compares the new skip-worktree value with the previous one. If
380+
skip-worktree turns from unset to set, it will add the corresponding
381+
file back. If it turns from set to unset, that file will be removed.
382+
383+
While `$GIT_DIR/info/sparse-checkout` is usually used to specify what
384+
files are in. You can also specify what files are _not_ in, using
385+
negate patterns. For example, to remove file "unwanted":
386+
387+
----------------
388+
*
389+
!unwanted
390+
----------------
391+
392+
Another tricky thing is fully repopulating working directory when you
393+
no longer want sparse checkout. You cannot just disable "sparse
394+
checkout" because skip-worktree are still in the index and you working
395+
directory is still sparsely populated. You should re-populate working
396+
directory with the `$GIT_DIR/info/sparse-checkout` file content as
397+
follows:
398+
399+
----------------
400+
*
401+
----------------
402+
403+
Then you can disable sparse checkout. Sparse checkout support in "git
404+
read-tree" and similar commands is disabled by default.
405+
406+
363407
SEE ALSO
364408
--------
365409
linkgit:git-write-tree[1]; linkgit:git-ls-files[1];

0 commit comments

Comments
 (0)