1GIT-LS-FILES(1)                   Git Manual                   GIT-LS-FILES(1)
2
3
4

NAME

6       git-ls-files - Show information about files in the index and the
7       working tree
8

SYNOPSIS

10       git ls-files [-z] [-t] [-v] [-f]
11                       [-c|--cached] [-d|--deleted] [-o|--others] [-i|--ignored]
12                       [-s|--stage] [-u|--unmerged] [-k|--killed] [-m|--modified]
13                       [--resolve-undo]
14                       [--directory [--no-empty-directory]] [--eol]
15                       [--deduplicate]
16                       [-x <pattern>|--exclude=<pattern>]
17                       [-X <file>|--exclude-from=<file>]
18                       [--exclude-per-directory=<file>]
19                       [--exclude-standard]
20                       [--error-unmatch] [--with-tree=<tree-ish>]
21                       [--full-name] [--recurse-submodules]
22                       [--abbrev[=<n>]] [--format=<format>] [--] [<file>...]
23

DESCRIPTION

25       This command merges the file listing in the index with the actual
26       working directory list, and shows different combinations of the two.
27
28       Several flags can be used to determine which files are shown, and each
29       file may be printed multiple times if there are multiple entries in the
30       index or if multiple statuses are applicable for the relevant file
31       selection options.
32

OPTIONS

34       -c, --cached
35           Show all files cached in Git’s index, i.e. all tracked files. (This
36           is the default if no -c/-s/-d/-o/-u/-k/-m/--resolve-undo options
37           are specified.)
38
39       -d, --deleted
40           Show files with an unstaged deletion
41
42       -m, --modified
43           Show files with an unstaged modification (note that an unstaged
44           deletion also counts as an unstaged modification)
45
46       -o, --others
47           Show other (i.e. untracked) files in the output
48
49       -i, --ignored
50           Show only ignored files in the output. Must be used with either an
51           explicit -c or -o. When showing files in the index (i.e. when used
52           with -c), print only those files matching an exclude pattern. When
53           showing "other" files (i.e. when used with -o), show only those
54           matched by an exclude pattern. Standard ignore rules are not
55           automatically activated; therefore, at least one of the --exclude*
56           options is required.
57
58       -s, --stage
59           Show staged contents' mode bits, object name and stage number in
60           the output.
61
62       --directory
63           If a whole directory is classified as "other", show just its name
64           (with a trailing slash) and not its whole contents. Has no effect
65           without -o/--others.
66
67       --no-empty-directory
68           Do not list empty directories. Has no effect without --directory.
69
70       -u, --unmerged
71           Show information about unmerged files in the output, but do not
72           show any other tracked files (forces --stage, overrides --cached).
73
74       -k, --killed
75           Show untracked files on the filesystem that need to be removed due
76           to file/directory conflicts for tracked files to be able to be
77           written to the filesystem.
78
79       --resolve-undo
80           Show files having resolve-undo information in the index together
81           with their resolve-undo information. (resolve-undo information is
82           what is used to implement "git checkout -m $PATH", i.e. to recreate
83           merge conflicts that were accidentally resolved)
84
85       -z
86           \0 line termination on output and do not quote filenames. See
87           OUTPUT below for more information.
88
89       --deduplicate
90           When only filenames are shown, suppress duplicates that may come
91           from having multiple stages during a merge, or giving --deleted and
92           --modified option at the same time. When any of the -t, --unmerged,
93           or --stage option is in use, this option has no effect.
94
95       -x <pattern>, --exclude=<pattern>
96           Skip untracked files matching pattern. Note that pattern is a shell
97           wildcard pattern. See EXCLUDE PATTERNS below for more information.
98
99       -X <file>, --exclude-from=<file>
100           Read exclude patterns from <file>; 1 per line.
101
102       --exclude-per-directory=<file>
103           Read additional exclude patterns that apply only to the directory
104           and its subdirectories in <file>. Deprecated; use
105           --exclude-standard instead.
106
107       --exclude-standard
108           Add the standard Git exclusions: .git/info/exclude, .gitignore in
109           each directory, and the user’s global exclusion file.
110
111       --error-unmatch
112           If any <file> does not appear in the index, treat this as an error
113           (return 1).
114
115       --with-tree=<tree-ish>
116           When using --error-unmatch to expand the user supplied <file> (i.e.
117           path pattern) arguments to paths, pretend that paths which were
118           removed in the index since the named <tree-ish> are still present.
119           Using this option with -s or -u options does not make any sense.
120
121       -t
122           Show status tags together with filenames. Note that for scripting
123           purposes, git-status(1) --porcelain and git-diff-files(1)
124           --name-status are almost always superior alternatives; users should
125           look at git-status(1) --short or git-diff(1) --name-status for more
126           user-friendly alternatives.
127
128           This option provides a reason for showing each filename, in the
129           form of a status tag (which is followed by a space and then the
130           filename). The status tags are all single characters from the
131           following list:
132
133           H
134               tracked file that is not either unmerged or skip-worktree
135
136           S
137               tracked file that is skip-worktree
138
139           M
140               tracked file that is unmerged
141
142           R
143               tracked file with unstaged removal/deletion
144
145           C
146               tracked file with unstaged modification/change
147
148           K
149               untracked paths which are part of file/directory conflicts
150               which prevent checking out tracked files
151
152           ?
153               untracked file
154
155           U
156               file with resolve-undo information
157
158       -v
159           Similar to -t, but use lowercase letters for files that are marked
160           as assume unchanged (see git-update-index(1)).
161
162       -f
163           Similar to -t, but use lowercase letters for files that are marked
164           as fsmonitor valid (see git-update-index(1)).
165
166       --full-name
167           When run from a subdirectory, the command usually outputs paths
168           relative to the current directory. This option forces paths to be
169           output relative to the project top directory.
170
171       --recurse-submodules
172           Recursively calls ls-files on each active submodule in the
173           repository. Currently there is only support for the --cached and
174           --stage modes.
175
176       --abbrev[=<n>]
177           Instead of showing the full 40-byte hexadecimal object lines, show
178           the shortest prefix that is at least <n> hexdigits long that
179           uniquely refers the object. Non default number of digits can be
180           specified with --abbrev=<n>.
181
182       --debug
183           After each line that describes a file, add more data about its
184           cache entry. This is intended to show as much information as
185           possible for manual inspection; the exact format may change at any
186           time.
187
188       --eol
189           Show <eolinfo> and <eolattr> of files. <eolinfo> is the file
190           content identification used by Git when the "text" attribute is
191           "auto" (or not set and core.autocrlf is not false). <eolinfo> is
192           either "-text", "none", "lf", "crlf", "mixed" or "".
193
194           "" means the file is not a regular file, it is not in the index or
195           not accessible in the working tree.
196
197           <eolattr> is the attribute that is used when checking out or
198           committing, it is either "", "-text", "text", "text=auto", "text
199           eol=lf", "text eol=crlf". Since Git 2.10 "text=auto eol=lf" and
200           "text=auto eol=crlf" are supported.
201
202           Both the <eolinfo> in the index ("i/<eolinfo>") and in the working
203           tree ("w/<eolinfo>") are shown for regular files, followed by the
204           ("attr/<eolattr>").
205
206       --sparse
207           If the index is sparse, show the sparse directories without
208           expanding to the contained files. Sparse directories will be shown
209           with a trailing slash, such as "x/" for a sparse directory "x".
210
211       --format=<format>
212           A string that interpolates %(fieldname) from the result being
213           shown. It also interpolates %% to %, and %xx where xx are hex
214           digits interpolates to character with hex code xx; for example %00
215           interpolates to \0 (NUL), %09 to \t (TAB) and %0a to \n (LF).
216           --format cannot be combined with -s, -o, -k, -t, --resolve-undo and
217           --eol.
218
219       --
220           Do not interpret any more arguments as options.
221
222       <file>
223           Files to show. If no files are given all files which match the
224           other specified criteria are shown.
225

OUTPUT

227       git ls-files just outputs the filenames unless --stage is specified in
228       which case it outputs:
229
230           [<tag> ]<mode> <object> <stage> <file>
231
232       git ls-files --eol will show
233       i/<eolinfo><SPACES>w/<eolinfo><SPACES>attr/<eolattr><SPACE*><TAB><file>
234
235       git ls-files --unmerged and git ls-files --stage can be used to examine
236       detailed information on unmerged paths.
237
238       For an unmerged path, instead of recording a single mode/SHA-1 pair,
239       the index records up to three such pairs; one from tree O in stage 1, A
240       in stage 2, and B in stage 3. This information can be used by the user
241       (or the porcelain) to see what should eventually be recorded at the
242       path. (see git-read-tree(1) for more information on state)
243
244       Without the -z option, pathnames with "unusual" characters are quoted
245       as explained for the configuration variable core.quotePath (see git-
246       config(1)). Using -z the filename is output verbatim and the line is
247       terminated by a NUL byte.
248
249       It is possible to print in a custom format by using the --format
250       option, which is able to interpolate different fields using a
251       %(fieldname) notation. For example, if you only care about the
252       "objectname" and "path" fields, you can execute with a specific
253       "--format" like
254
255           git ls-files --format='%(objectname) %(path)'
256

FIELD NAMES

258       The way each path is shown can be customized by using the
259       --format=<format> option, where the %(fieldname) in the <format> string
260       for various aspects of the index entry are interpolated. The following
261       "fieldname" are understood:
262
263       objectmode
264           The mode of the file which is recorded in the index.
265
266       objecttype
267           The object type of the file which is recorded in the index.
268
269       objectname
270           The name of the file which is recorded in the index.
271
272       objectsize[:padded]
273           The object size of the file which is recorded in the index ("-" if
274           the object is a commit or tree). It also supports a padded format
275           of size with "%(objectsize:padded)".
276
277       stage
278           The stage of the file which is recorded in the index.
279
280       eolinfo:index, eolinfo:worktree
281           The <eolinfo> (see the description of the --eol option) of the
282           contents in the index or in the worktree for the path.
283
284       eolattr
285           The <eolattr> (see the description of the --eol option) that
286           applies to the path.
287
288       path
289           The pathname of the file which is recorded in the index.
290

EXCLUDE PATTERNS

292       git ls-files can use a list of "exclude patterns" when traversing the
293       directory tree and finding files to show when the flags --others or
294       --ignored are specified. gitignore(5) specifies the format of exclude
295       patterns.
296
297       Generally, you should just use --exclude-standard, but for historical
298       reasons the exclude patterns can be specified from the following
299       places, in order:
300
301        1. The command-line flag --exclude=<pattern> specifies a single
302           pattern. Patterns are ordered in the same order they appear in the
303           command line.
304
305        2. The command-line flag --exclude-from=<file> specifies a file
306           containing a list of patterns. Patterns are ordered in the same
307           order they appear in the file.
308
309        3. The command-line flag --exclude-per-directory=<name> specifies a
310           name of the file in each directory git ls-files examines, normally
311           .gitignore. Files in deeper directories take precedence. Patterns
312           are ordered in the same order they appear in the files.
313
314       A pattern specified on the command line with --exclude or read from the
315       file specified with --exclude-from is relative to the top of the
316       directory tree. A pattern read from a file specified by
317       --exclude-per-directory is relative to the directory that the pattern
318       file appears in.
319

SEE ALSO

321       git-read-tree(1), gitignore(5)
322

GIT

324       Part of the git(1) suite
325
326
327
328Git 2.43.0                        11/20/2023                   GIT-LS-FILES(1)
Impressum