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                       [--directory [--no-empty-directory]] [--eol]
14                       [--deduplicate]
15                       [-x <pattern>|--exclude=<pattern>]
16                       [-X <file>|--exclude-from=<file>]
17                       [--exclude-per-directory=<file>]
18                       [--exclude-standard]
19                       [--error-unmatch] [--with-tree=<tree-ish>]
20                       [--full-name] [--recurse-submodules]
21                       [--abbrev[=<n>]] [--format=<format>] [--] [<file>...]
22

DESCRIPTION

24       This merges the file listing in the index with the actual working
25       directory list, and shows different combinations of the two.
26
27       One or more of the options below may be used to determine the files
28       shown:
29

OPTIONS

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

OUTPUT

203       git ls-files just outputs the filenames unless --stage is specified in
204       which case it outputs:
205
206           [<tag> ]<mode> <object> <stage> <file>
207
208       git ls-files --eol will show
209       i/<eolinfo><SPACES>w/<eolinfo><SPACES>attr/<eolattr><SPACE*><TAB><file>
210
211       git ls-files --unmerged and git ls-files --stage can be used to examine
212       detailed information on unmerged paths.
213
214       For an unmerged path, instead of recording a single mode/SHA-1 pair,
215       the index records up to three such pairs; one from tree O in stage 1, A
216       in stage 2, and B in stage 3. This information can be used by the user
217       (or the porcelain) to see what should eventually be recorded at the
218       path. (see git-read-tree(1) for more information on state)
219
220       Without the -z option, pathnames with "unusual" characters are quoted
221       as explained for the configuration variable core.quotePath (see git-
222       config(1)). Using -z the filename is output verbatim and the line is
223       terminated by a NUL byte.
224
225       It is possible to print in a custom format by using the --format
226       option, which is able to interpolate different fields using a
227       %(fieldname) notation. For example, if you only care about the
228       "objectname" and "path" fields, you can execute with a specific
229       "--format" like
230
231           git ls-files --format='%(objectname) %(path)'
232

FIELD NAMES

234       The way each path is shown can be customized by using the
235       --format=<format> option, where the %(fieldname) in the <format> string
236       for various aspects of the index entry are interpolated. The following
237       "fieldname" are understood:
238
239       objectmode
240           The mode of the file which is recorded in the index.
241
242       objectname
243           The name of the file which is recorded in the index.
244
245       stage
246           The stage of the file which is recorded in the index.
247
248       eolinfo:index, eolinfo:worktree
249           The <eolinfo> (see the description of the --eol option) of the
250           contents in the index or in the worktree for the path.
251
252       eolattr
253           The <eolattr> (see the description of the --eol option) that
254           applies to the path.
255
256       path
257           The pathname of the file which is recorded in the index.
258

EXCLUDE PATTERNS

260       git ls-files can use a list of "exclude patterns" when traversing the
261       directory tree and finding files to show when the flags --others or
262       --ignored are specified. gitignore(5) specifies the format of exclude
263       patterns.
264
265       These exclude patterns come from these places, in order:
266
267        1. The command-line flag --exclude=<pattern> specifies a single
268           pattern. Patterns are ordered in the same order they appear in the
269           command line.
270
271        2. The command-line flag --exclude-from=<file> specifies a file
272           containing a list of patterns. Patterns are ordered in the same
273           order they appear in the file.
274
275        3. The command-line flag --exclude-per-directory=<name> specifies a
276           name of the file in each directory git ls-files examines, normally
277           .gitignore. Files in deeper directories take precedence. Patterns
278           are ordered in the same order they appear in the files.
279
280       A pattern specified on the command line with --exclude or read from the
281       file specified with --exclude-from is relative to the top of the
282       directory tree. A pattern read from a file specified by
283       --exclude-per-directory is relative to the directory that the pattern
284       file appears in.
285

SEE ALSO

287       git-read-tree(1), gitignore(5)
288

GIT

290       Part of the git(1) suite
291
292
293
294Git 2.39.1                        2023-01-13                   GIT-LS-FILES(1)
Impressum