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];