@matheusbsbs / matheus-bagliano / commits / ed5336a754
Fork 0

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 <pclouds@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Nguyễn Thái Ngọc Duy committed Aug 20, 2009 at 20:47 UTC ed5336a7541e19b267de53afc8d15cffdbde8286
1 file changed +44
Documentation/git-read-tree.txt
+44
@@ -360,6 +360,50 @@ middle of doing, and when your working tree is ready (i.e. you
360 have finished your work-in-progress), attempt the merge again.
361
362
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 +
407 SEE ALSO
408 --------
409 linkgit:git-write-tree[1]; linkgit:git-ls-files[1];