Skip to content

Commit 5d295dc

Browse files
newrengitster
authored andcommitted
git-sparse-checkout.txt: add a new EXAMPLES section
Since many users like to learn from examples, provide a section in the manual with example commands that would be used and a brief explanation of what each does. Signed-off-by: Elijah Newren <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 0d86f59 commit 5d295dc

File tree

1 file changed

+37
-6
lines changed

1 file changed

+37
-6
lines changed

Documentation/git-sparse-checkout.txt

Lines changed: 37 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,43 @@ paths to pass to a subsequent 'set' or 'add' command. However,
136136
the disable command, so the easy restore of calling a plain `init`
137137
decreased in utility.
138138

139+
EXAMPLES
140+
--------
141+
`git sparse-checkout set MY/DIR1 SUB/DIR2`::
142+
143+
Change to a sparse checkout with all files (at any depth) under
144+
MY/DIR1/ and SUB/DIR2/ present in the working copy (plus all
145+
files immediately under MY/ and SUB/ and the toplevel
146+
directory). If already in a sparse checkout, change which files
147+
are present in the working copy to this new selection. Note
148+
that this command will also delete all ignored files in any
149+
directory that no longer has either tracked or
150+
non-ignored-untracked files present.
151+
152+
`git sparse-checkout disable`::
153+
154+
Repopulate the working directory with all files, disabling sparse
155+
checkouts.
156+
157+
`git sparse-checkout add SOME/DIR/ECTORY`::
158+
159+
Add all files under SOME/DIR/ECTORY/ (at any depth) to the
160+
sparse checkout, as well as all files immediately under
161+
SOME/DIR/ and immediately under SOME/. Must already be in a
162+
sparse checkout before using this command.
163+
164+
`git sparse-checkout reapply`::
165+
166+
It is possible for commands to update the working tree in a
167+
way that does not respect the selected sparsity directories.
168+
This can come from tools external to Git writing files, or
169+
even affect Git commands because of either special cases (such
170+
as hitting conflicts when merging/rebasing), or because some
171+
commands didn't fully support sparse checkouts (e.g. the old
172+
`recursive` merge backend had only limited support). This
173+
command reapplies the existing sparse directory specifications
174+
to make the working directory match.
175+
139176
INTERNALS -- SPARSE CHECKOUT
140177
----------------------------
141178

@@ -154,12 +191,6 @@ directory, it updates the skip-worktree bits in the index based
154191
on this file. The files matching the patterns in the file will
155192
appear in the working directory, and the rest will not.
156193

157-
To enable the sparse-checkout feature, run `git sparse-checkout set` to
158-
set the patterns you want to use.
159-
160-
To repopulate the working directory with all files, use the
161-
`git sparse-checkout disable` command.
162-
163194

164195
INTERNALS -- CONE PATTERN SET
165196
-----------------------------

0 commit comments

Comments
 (0)