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>]] [--] [<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       --
188           Do not interpret any more arguments as options.
189
190       <file>
191           Files to show. If no files are given all files which match the
192           other specified criteria are shown.
193

OUTPUT

195       git ls-files just outputs the filenames unless --stage is specified in
196       which case it outputs:
197
198           [<tag> ]<mode> <object> <stage> <file>
199
200       git ls-files --eol will show
201       i/<eolinfo><SPACES>w/<eolinfo><SPACES>attr/<eolattr><SPACE*><TAB><file>
202
203       git ls-files --unmerged and git ls-files --stage can be used to examine
204       detailed information on unmerged paths.
205
206       For an unmerged path, instead of recording a single mode/SHA-1 pair,
207       the index records up to three such pairs; one from tree O in stage 1, A
208       in stage 2, and B in stage 3. This information can be used by the user
209       (or the porcelain) to see what should eventually be recorded at the
210       path. (see git-read-tree(1) for more information on state)
211
212       Without the -z option, pathnames with "unusual" characters are quoted
213       as explained for the configuration variable core.quotePath (see git-
214       config(1)). Using -z the filename is output verbatim and the line is
215       terminated by a NUL byte.
216

EXCLUDE PATTERNS

218       git ls-files can use a list of "exclude patterns" when traversing the
219       directory tree and finding files to show when the flags --others or
220       --ignored are specified. gitignore(5) specifies the format of exclude
221       patterns.
222
223       These exclude patterns come from these places, in order:
224
225        1. The command-line flag --exclude=<pattern> specifies a single
226           pattern. Patterns are ordered in the same order they appear in the
227           command line.
228
229        2. The command-line flag --exclude-from=<file> specifies a file
230           containing a list of patterns. Patterns are ordered in the same
231           order they appear in the file.
232
233        3. The command-line flag --exclude-per-directory=<name> specifies a
234           name of the file in each directory git ls-files examines, normally
235           .gitignore. Files in deeper directories take precedence. Patterns
236           are ordered in the same order they appear in the files.
237
238       A pattern specified on the command line with --exclude or read from the
239       file specified with --exclude-from is relative to the top of the
240       directory tree. A pattern read from a file specified by
241       --exclude-per-directory is relative to the directory that the pattern
242       file appears in.
243

SEE ALSO

245       git-read-tree(1), gitignore(5)
246

GIT

248       Part of the git(1) suite
249
250
251
252Git 2.36.1                        2022-05-05                   GIT-LS-FILES(1)
Impressum