summaryrefslogtreecommitdiffstats
path: root/man1/git-ls-files.1
blob: fa39591acd7cc70cf86fdcb451fd3b72309c572b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
'\" t
.\"     Title: git-ls-files
.\"    Author: [FIXME: author] [see http://www.docbook.org/tdg5/en/html/author]
.\" Generator: DocBook XSL Stylesheets vsnapshot <http://docbook.sf.net/>
.\"      Date: 2024-04-09
.\"    Manual: Git Manual
.\"    Source: Git 2.44.0.548.g91ec36f2cc
.\"  Language: English
.\"
.TH "GIT\-LS\-FILES" "1" "2024\-04\-09" "Git 2\&.44\&.0\&.548\&.g91ec36" "Git Manual"
.\" -----------------------------------------------------------------
.\" * Define some portability stuff
.\" -----------------------------------------------------------------
.\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
.\" http://bugs.debian.org/507673
.\" http://lists.gnu.org/archive/html/groff/2009-02/msg00013.html
.\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
.ie \n(.g .ds Aq \(aq
.el       .ds Aq '
.\" -----------------------------------------------------------------
.\" * set default formatting
.\" -----------------------------------------------------------------
.\" disable hyphenation
.nh
.\" disable justification (adjust text to left margin only)
.ad l
.\" -----------------------------------------------------------------
.\" * MAIN CONTENT STARTS HERE *
.\" -----------------------------------------------------------------
.SH "NAME"
git-ls-files \- Show information about files in the index and the working tree
.SH "SYNOPSIS"
.sp
.nf
\fIgit ls\-files\fR [\-z] [\-t] [\-v] [\-f]
                [\-c|\-\-cached] [\-d|\-\-deleted] [\-o|\-\-others] [\-i|\-\-ignored]
                [\-s|\-\-stage] [\-u|\-\-unmerged] [\-k|\-\-killed] [\-m|\-\-modified]
                [\-\-resolve\-undo]
                [\-\-directory [\-\-no\-empty\-directory]] [\-\-eol]
                [\-\-deduplicate]
                [\-x <pattern>|\-\-exclude=<pattern>]
                [\-X <file>|\-\-exclude\-from=<file>]
                [\-\-exclude\-per\-directory=<file>]
                [\-\-exclude\-standard]
                [\-\-error\-unmatch] [\-\-with\-tree=<tree\-ish>]
                [\-\-full\-name] [\-\-recurse\-submodules]
                [\-\-abbrev[=<n>]] [\-\-format=<format>] [\-\-] [<file>\&...]
.fi
.sp
.SH "DESCRIPTION"
.sp
This command merges the file listing in the index with the actual working directory list, and shows different combinations of the two\&.
.sp
Several flags can be used to determine which files are shown, and each file may be printed multiple times if there are multiple entries in the index or if multiple statuses are applicable for the relevant file selection options\&.
.SH "OPTIONS"
.PP
\-c, \-\-cached
.RS 4
Show all files cached in Git\(cqs index, i\&.e\&. all tracked files\&. (This is the default if no \-c/\-s/\-d/\-o/\-u/\-k/\-m/\-\-resolve\-undo options are specified\&.)
.RE
.PP
\-d, \-\-deleted
.RS 4
Show files with an unstaged deletion
.RE
.PP
\-m, \-\-modified
.RS 4
Show files with an unstaged modification (note that an unstaged deletion also counts as an unstaged modification)
.RE
.PP
\-o, \-\-others
.RS 4
Show other (i\&.e\&. untracked) files in the output
.RE
.PP
\-i, \-\-ignored
.RS 4
Show only ignored files in the output\&. Must be used with either an explicit
\fI\-c\fR
or
\fI\-o\fR\&. When showing files in the index (i\&.e\&. when used with
\fI\-c\fR), print only those files matching an exclude pattern\&. When showing "other" files (i\&.e\&. when used with
\fI\-o\fR), show only those matched by an exclude pattern\&. Standard ignore rules are not automatically activated; therefore, at least one of the
\fB\-\-exclude*\fR
options is required\&.
.RE
.PP
\-s, \-\-stage
.RS 4
Show staged contents\*(Aq mode bits, object name and stage number in the output\&.
.RE
.PP
\-\-directory
.RS 4
If a whole directory is classified as "other", show just its name (with a trailing slash) and not its whole contents\&. Has no effect without \-o/\-\-others\&.
.RE
.PP
\-\-no\-empty\-directory
.RS 4
Do not list empty directories\&. Has no effect without \-\-directory\&.
.RE
.PP
\-u, \-\-unmerged
.RS 4
Show information about unmerged files in the output, but do not show any other tracked files (forces \-\-stage, overrides \-\-cached)\&.
.RE
.PP
\-k, \-\-killed
.RS 4
Show untracked files on the filesystem that need to be removed due to file/directory conflicts for tracked files to be able to be written to the filesystem\&.
.RE
.PP
\-\-resolve\-undo
.RS 4
Show files having resolve\-undo information in the index together with their resolve\-undo information\&. (resolve\-undo information is what is used to implement "git checkout \-m $PATH", i\&.e\&. to recreate merge conflicts that were accidentally resolved)
.RE
.PP
\-z
.RS 4
\e0 line termination on output and do not quote filenames\&. See OUTPUT below for more information\&.
.RE
.PP
\-\-deduplicate
.RS 4
When only filenames are shown, suppress duplicates that may come from having multiple stages during a merge, or giving
\fB\-\-deleted\fR
and
\fB\-\-modified\fR
option at the same time\&. When any of the
\fB\-t\fR,
\fB\-\-unmerged\fR, or
\fB\-\-stage\fR
option is in use, this option has no effect\&.
.RE
.PP
\-x <pattern>, \-\-exclude=<pattern>
.RS 4
Skip untracked files matching pattern\&. Note that pattern is a shell wildcard pattern\&. See EXCLUDE PATTERNS below for more information\&.
.RE
.PP
\-X <file>, \-\-exclude\-from=<file>
.RS 4
Read exclude patterns from <file>; 1 per line\&.
.RE
.PP
\-\-exclude\-per\-directory=<file>
.RS 4
Read additional exclude patterns that apply only to the directory and its subdirectories in <file>\&. If you are trying to emulate the way Porcelain commands work, using the
\fB\-\-exclude\-standard\fR
option instead is easier and more thorough\&.
.RE
.PP
\-\-exclude\-standard
.RS 4
Add the standard Git exclusions: \&.git/info/exclude, \&.gitignore in each directory, and the user\(cqs global exclusion file\&.
.RE
.PP
\-\-error\-unmatch
.RS 4
If any <file> does not appear in the index, treat this as an error (return 1)\&.
.RE
.PP
\-\-with\-tree=<tree\-ish>
.RS 4
When using \-\-error\-unmatch to expand the user supplied <file> (i\&.e\&. path pattern) arguments to paths, pretend that paths which were removed in the index since the named <tree\-ish> are still present\&. Using this option with
\fB\-s\fR
or
\fB\-u\fR
options does not make any sense\&.
.RE
.PP
\-t
.RS 4
Show status tags together with filenames\&. Note that for scripting purposes,
\fBgit-status\fR(1)
\fB\-\-porcelain\fR
and
\fBgit-diff-files\fR(1)
\fB\-\-name\-status\fR
are almost always superior alternatives; users should look at
\fBgit-status\fR(1)
\fB\-\-short\fR
or
\fBgit-diff\fR(1)
\fB\-\-name\-status\fR
for more user\-friendly alternatives\&.
.sp
This option provides a reason for showing each filename, in the form of a status tag (which is followed by a space and then the filename)\&. The status tags are all single characters from the following list:
.PP
H
.RS 4
tracked file that is not either unmerged or skip\-worktree
.RE
.PP
S
.RS 4
tracked file that is skip\-worktree
.RE
.PP
M
.RS 4
tracked file that is unmerged
.RE
.PP
R
.RS 4
tracked file with unstaged removal/deletion
.RE
.PP
C
.RS 4
tracked file with unstaged modification/change
.RE
.PP
K
.RS 4
untracked paths which are part of file/directory conflicts which prevent checking out tracked files
.RE
.PP
?
.RS 4
untracked file
.RE
.PP
U
.RS 4
file with resolve\-undo information
.RE
.RE
.PP
\-v
.RS 4
Similar to
\fB\-t\fR, but use lowercase letters for files that are marked as
\fIassume unchanged\fR
(see
\fBgit-update-index\fR(1))\&.
.RE
.PP
\-f
.RS 4
Similar to
\fB\-t\fR, but use lowercase letters for files that are marked as
\fIfsmonitor valid\fR
(see
\fBgit-update-index\fR(1))\&.
.RE
.PP
\-\-full\-name
.RS 4
When run from a subdirectory, the command usually outputs paths relative to the current directory\&. This option forces paths to be output relative to the project top directory\&.
.RE
.PP
\-\-recurse\-submodules
.RS 4
Recursively calls ls\-files on each active submodule in the repository\&. Currently there is only support for the \-\-cached and \-\-stage modes\&.
.RE
.PP
\-\-abbrev[=<n>]
.RS 4
Instead of showing the full 40\-byte hexadecimal object lines, show the shortest prefix that is at least
\fI<n>\fR
hexdigits long that uniquely refers the object\&. Non default number of digits can be specified with \-\-abbrev=<n>\&.
.RE
.PP
\-\-debug
.RS 4
After each line that describes a file, add more data about its cache entry\&. This is intended to show as much information as possible for manual inspection; the exact format may change at any time\&.
.RE
.PP
\-\-eol
.RS 4
Show <eolinfo> and <eolattr> of files\&. <eolinfo> is the file content identification used by Git when the "text" attribute is "auto" (or not set and core\&.autocrlf is not false)\&. <eolinfo> is either "\-text", "none", "lf", "crlf", "mixed" or ""\&.
.sp
"" means the file is not a regular file, it is not in the index or not accessible in the working tree\&.
.sp
<eolattr> is the attribute that is used when checking out or committing, it is either "", "\-text", "text", "text=auto", "text eol=lf", "text eol=crlf"\&. Since Git 2\&.10 "text=auto eol=lf" and "text=auto eol=crlf" are supported\&.
.sp
Both the <eolinfo> in the index ("i/<eolinfo>") and in the working tree ("w/<eolinfo>") are shown for regular files, followed by the ("attr/<eolattr>")\&.
.RE
.PP
\-\-sparse
.RS 4
If the index is sparse, show the sparse directories without expanding to the contained files\&. Sparse directories will be shown with a trailing slash, such as "x/" for a sparse directory "x"\&.
.RE
.PP
\-\-format=<format>
.RS 4
A string that interpolates
\fB%(fieldname)\fR
from the result being shown\&. It also interpolates
\fB%%\fR
to
\fB%\fR, and
\fB%xx\fR
where
\fBxx\fR
are hex digits interpolates to character with hex code
\fBxx\fR; for example
\fB%00\fR
interpolates to
\fB\e0\fR
(NUL),
\fB%09\fR
to
\fB\et\fR
(TAB) and %0a to
\fB\en\fR
(LF)\&. \-\-format cannot be combined with
\fB\-s\fR,
\fB\-o\fR,
\fB\-k\fR,
\fB\-t\fR,
\fB\-\-resolve\-undo\fR
and
\fB\-\-eol\fR\&.
.RE
.PP
\-\-
.RS 4
Do not interpret any more arguments as options\&.
.RE
.PP
<file>
.RS 4
Files to show\&. If no files are given all files which match the other specified criteria are shown\&.
.RE
.SH "OUTPUT"
.sp
\fIgit ls\-files\fR just outputs the filenames unless \fB\-\-stage\fR is specified in which case it outputs:
.sp
.if n \{\
.RS 4
.\}
.nf
[<tag> ]<mode> <object> <stage> <file>
.fi
.if n \{\
.RE
.\}
.sp
\fIgit ls\-files \-\-eol\fR will show i/<eolinfo><SPACES>w/<eolinfo><SPACES>attr/<eolattr><SPACE*><TAB><file>
.sp
\fIgit ls\-files \-\-unmerged\fR and \fIgit ls\-files \-\-stage\fR can be used to examine detailed information on unmerged paths\&.
.sp
For an unmerged path, instead of recording a single mode/SHA\-1 pair, the index records up to three such pairs; one from tree O in stage 1, A in stage 2, and B in stage 3\&. This information can be used by the user (or the porcelain) to see what should eventually be recorded at the path\&. (see \fBgit-read-tree\fR(1) for more information on state)
.sp
Without the \fB\-z\fR option, pathnames with "unusual" characters are quoted as explained for the configuration variable \fBcore\&.quotePath\fR (see \fBgit-config\fR(1))\&. Using \fB\-z\fR the filename is output verbatim and the line is terminated by a NUL byte\&.
.sp
It is possible to print in a custom format by using the \fB\-\-format\fR option, which is able to interpolate different fields using a \fB%(fieldname)\fR notation\&. For example, if you only care about the "objectname" and "path" fields, you can execute with a specific "\-\-format" like
.sp
.if n \{\
.RS 4
.\}
.nf
git ls\-files \-\-format=\*(Aq%(objectname) %(path)\*(Aq
.fi
.if n \{\
.RE
.\}
.SH "FIELD NAMES"
.sp
The way each path is shown can be customized by using the \fB\-\-format=<format>\fR option, where the %(fieldname) in the <format> string for various aspects of the index entry are interpolated\&. The following "fieldname" are understood:
.PP
objectmode
.RS 4
The mode of the file which is recorded in the index\&.
.RE
.PP
objecttype
.RS 4
The object type of the file which is recorded in the index\&.
.RE
.PP
objectname
.RS 4
The name of the file which is recorded in the index\&.
.RE
.PP
objectsize[:padded]
.RS 4
The object size of the file which is recorded in the index ("\-" if the object is a
\fBcommit\fR
or
\fBtree\fR)\&. It also supports a padded format of size with "%(objectsize:padded)"\&.
.RE
.PP
stage
.RS 4
The stage of the file which is recorded in the index\&.
.RE
.PP
eolinfo:index, eolinfo:worktree
.RS 4
The <eolinfo> (see the description of the
\fB\-\-eol\fR
option) of the contents in the index or in the worktree for the path\&.
.RE
.PP
eolattr
.RS 4
The <eolattr> (see the description of the
\fB\-\-eol\fR
option) that applies to the path\&.
.RE
.PP
path
.RS 4
The pathname of the file which is recorded in the index\&.
.RE
.SH "EXCLUDE PATTERNS"
.sp
\fIgit ls\-files\fR can use a list of "exclude patterns" when traversing the directory tree and finding files to show when the flags \-\-others or \-\-ignored are specified\&. \fBgitignore\fR(5) specifies the format of exclude patterns\&.
.sp
These exclude patterns can be specified from the following places, in order:
.sp
.RS 4
.ie n \{\
\h'-04' 1.\h'+01'\c
.\}
.el \{\
.sp -1
.IP "  1." 4.2
.\}
The command\-line flag \-\-exclude=<pattern> specifies a single pattern\&. Patterns are ordered in the same order they appear in the command line\&.
.RE
.sp
.RS 4
.ie n \{\
\h'-04' 2.\h'+01'\c
.\}
.el \{\
.sp -1
.IP "  2." 4.2
.\}
The command\-line flag \-\-exclude\-from=<file> specifies a file containing a list of patterns\&. Patterns are ordered in the same order they appear in the file\&.
.RE
.sp
.RS 4
.ie n \{\
\h'-04' 3.\h'+01'\c
.\}
.el \{\
.sp -1
.IP "  3." 4.2
.\}
The command\-line flag \-\-exclude\-per\-directory=<name> specifies a name of the file in each directory
\fIgit ls\-files\fR
examines, normally
\fB\&.gitignore\fR\&. Files in deeper directories take precedence\&. Patterns are ordered in the same order they appear in the files\&.
.RE
.sp
A pattern specified on the command line with \-\-exclude or read from the file specified with \-\-exclude\-from is relative to the top of the directory tree\&. A pattern read from a file specified by \-\-exclude\-per\-directory is relative to the directory that the pattern file appears in\&.
.sp
Generally, you should be able to use \fB\-\-exclude\-standard\fR when you want the exclude rules applied the same way as what Porcelain commands do\&. To emulate what \fB\-\-exclude\-standard\fR specifies, you can give \fB\-\-exclude\-per\-directory=\&.gitignore\fR, and then specify:
.sp
.RS 4
.ie n \{\
\h'-04' 1.\h'+01'\c
.\}
.el \{\
.sp -1
.IP "  1." 4.2
.\}
The file specified by the
\fBcore\&.excludesfile\fR
configuration variable, if exists, or the
\fB$XDG_CONFIG_HOME/git/ignore\fR
file\&.
.RE
.sp
.RS 4
.ie n \{\
\h'-04' 2.\h'+01'\c
.\}
.el \{\
.sp -1
.IP "  2." 4.2
.\}
The
\fB$GIT_DIR/info/exclude\fR
file\&.
.RE
.sp
via the \fB\-\-exclude\-from=\fR option\&.
.SH "SEE ALSO"
.sp
\fBgit-read-tree\fR(1), \fBgitignore\fR(5)
.SH "GIT"
.sp
Part of the \fBgit\fR(1) suite