blob: 6d11ab506b7c2e0990c93822970cd079e34b6c04 [file] [log] [blame]
Junio C Hamano1a4e8412005-12-27 08:17:231git-ls-files(1)
2===============
3
4NAME
5----
Junio C Hamano7c73c662007-01-19 00:37:506git-ls-files - Show information about files in the index and the working tree
Junio C Hamano1a4e8412005-12-27 08:17:237
8
9SYNOPSIS
10--------
Junio C Hamano7e9f6b72006-02-22 10:44:5511[verse]
Junio C Hamanod7105602017-11-21 05:32:5012'git ls-files' [-z] [-t] [-v] [-f]
Junio C Hamano2db3e752010-09-03 21:33:0613(--[cached|deleted|others|ignored|stage|unmerged|killed|modified])*
14(-[c|d|o|i|s|u|k|m])*
Junio C Hamanoffe10ca2016-02-04 00:44:2315[--eol]
Junio C Hamano8c860d62021-02-06 01:37:4716[--deduplicate]
Junio C Hamano1a4e8412005-12-27 08:17:2317[-x <pattern>|--exclude=<pattern>]
18[-X <file>|--exclude-from=<file>]
Junio C Hamano5c3957e2006-03-28 00:28:0119[--exclude-per-directory=<file>]
Junio C Hamanoff979792007-11-16 10:11:3020[--exclude-standard]
Junio C Hamano58155b42007-09-15 07:46:1421[--error-unmatch] [--with-tree=<tree-ish>]
Junio C Hamano4a401d52016-10-26 22:24:3722[--full-name] [--recurse-submodules]
Junio C Hamanoee43d182020-11-11 22:10:4123[--abbrev[=<n>]] [--] [<file>...]
Junio C Hamano1a4e8412005-12-27 08:17:2324
25DESCRIPTION
26-----------
Junio C Hamano7887f9b2021-01-25 23:32:3327This merges the file listing in the index with the actual working
28directory list, and shows different combinations of the two.
Junio C Hamano1a4e8412005-12-27 08:17:2329
30One or more of the options below may be used to determine the files
31shown:
32
33OPTIONS
34-------
Junio C Hamanoeb415992008-06-08 22:49:4735-c::
36--cached::
Junio C Hamano1a4e8412005-12-27 08:17:2337Show cached files in the output (default)
38
Junio C Hamanoeb415992008-06-08 22:49:4739-d::
40--deleted::
Junio C Hamano1a4e8412005-12-27 08:17:2341Show deleted files in the output
42
Junio C Hamanoeb415992008-06-08 22:49:4743-m::
44--modified::
Junio C Hamano1a4e8412005-12-27 08:17:2345Show modified files in the output
46
Junio C Hamanoeb415992008-06-08 22:49:4747-o::
48--others::
Junio C Hamano31cca162009-08-07 05:40:0149Show other (i.e. untracked) files in the output
Junio C Hamano1a4e8412005-12-27 08:17:2350
Junio C Hamanoeb415992008-06-08 22:49:4751-i::
52--ignored::
Junio C Hamano446ed772009-11-10 22:02:2053Show only ignored files in the output. When showing files in the
54index, print only those matched by an exclude pattern. When
55showing "other" files, show only those matched by an exclude
Junio C Hamanob9d9d902018-05-23 07:07:4256pattern. Standard ignore rules are not automatically activated,
57therefore at least one of the `--exclude*` options is required.
Junio C Hamano1a4e8412005-12-27 08:17:2358
Junio C Hamanoeb415992008-06-08 22:49:4759-s::
60--stage::
Junio C Hamano761b4812017-04-17 07:27:5961Show staged contents' mode bits, object name and stage number in the output.
Junio C Hamano1a4e8412005-12-27 08:17:2362
Junio C Hamanoa6331a82006-01-22 07:50:3363--directory::
64If a whole directory is classified as "other", show just its
65name (with a trailing slash) and not its whole contents.
66
Junio C Hamanof02e09f2006-03-27 07:51:0367--no-empty-directory::
68Do not list empty directories. Has no effect without --directory.
69
Junio C Hamanoeb415992008-06-08 22:49:4770-u::
71--unmerged::
Junio C Hamano1a4e8412005-12-27 08:17:2372Show unmerged files in the output (forces --stage)
73
Junio C Hamanoeb415992008-06-08 22:49:4774-k::
75--killed::
Junio C Hamano1a4e8412005-12-27 08:17:2376Show files on the filesystem that need to be removed due
77to file/directory conflicts for checkout-index to
78succeed.
79
80-z::
Junio C Hamano0f6f3bf2017-03-13 07:01:5381\0 line termination on output and do not quote filenames.
82See OUTPUT below for more information.
Junio C Hamano1a4e8412005-12-27 08:17:2383
Junio C Hamano8c860d62021-02-06 01:37:4784--deduplicate::
85When only filenames are shown, suppress duplicates that may
86come from having multiple stages during a merge, or giving
87`--deleted` and `--modified` option at the same time.
88When any of the `-t`, `--unmerged`, or `--stage` option is
89in use, this option has no effect.
90
Junio C Hamanoeb415992008-06-08 22:49:4791-x <pattern>::
92--exclude=<pattern>::
Junio C Hamanoac752fa2010-09-19 00:01:0093Skip untracked files matching pattern.
94Note that pattern is a shell wildcard pattern. See EXCLUDE PATTERNS
95below for more information.
Junio C Hamano1a4e8412005-12-27 08:17:2396
Junio C Hamanoeb415992008-06-08 22:49:4797-X <file>::
98--exclude-from=<file>::
Junio C Hamanoac752fa2010-09-19 00:01:0099Read exclude patterns from <file>; 1 per line.
Junio C Hamano1a4e8412005-12-27 08:17:23100
101--exclude-per-directory=<file>::
Junio C Hamanoac752fa2010-09-19 00:01:00102Read additional exclude patterns that apply only to the
Junio C Hamano1a4e8412005-12-27 08:17:23103directory and its subdirectories in <file>.
104
Junio C Hamanoff979792007-11-16 10:11:30105--exclude-standard::
Junio C Hamano076ffcc2013-02-06 05:13:21106Add the standard Git exclusions: .git/info/exclude, .gitignore
Junio C Hamanoff979792007-11-16 10:11:30107in each directory, and the user's global exclusion file.
108
Junio C Hamano7e9f6b72006-02-22 10:44:55109--error-unmatch::
110If any <file> does not appear in the index, treat this as an
111error (return 1).
112
Junio C Hamano58155b42007-09-15 07:46:14113--with-tree=<tree-ish>::
114When using --error-unmatch to expand the user supplied
115<file> (i.e. path pattern) arguments to paths, pretend
116that paths which were removed in the index since the
117named <tree-ish> are still present. Using this option
118with `-s` or `-u` options does not make any sense.
119
Junio C Hamano1a4e8412005-12-27 08:17:23120-t::
Junio C Hamanoa9788762010-08-03 15:15:54121This feature is semi-deprecated. For scripting purpose,
122linkgit:git-status[1] `--porcelain` and
123linkgit:git-diff-files[1] `--name-status` are almost always
124superior alternatives, and users should look at
125linkgit:git-status[1] `--short` or linkgit:git-diff[1]
126`--name-status` for more user-friendly alternatives.
127+
Junio C Hamano792b6092019-05-13 16:03:59128--
Junio C Hamanoa9788762010-08-03 15:15:54129This option identifies the file status with the following tags (followed by
130a space) at the start of each line:
131
Junio C Hamano1a4e8412005-12-27 08:17:23132H:: cached
Junio C Hamano3c8d6702010-01-13 23:09:03133S:: skip-worktree
Junio C Hamano1a4e8412005-12-27 08:17:23134M:: unmerged
135R:: removed/deleted
Junio C Hamano235a91e2006-01-07 01:13:58136C:: modified/changed
Junio C Hamano1a4e8412005-12-27 08:17:23137K:: to be killed
Junio C Hamano6697ac52006-02-14 08:00:23138?:: other
Junio C Hamano792b6092019-05-13 16:03:59139--
Junio C Hamano1a4e8412005-12-27 08:17:23140
Junio C Hamano7e9f6b72006-02-22 10:44:55141-v::
142Similar to `-t`, but use lowercase letters for files
Junio C Hamanof556fc22007-12-23 08:16:38143that are marked as 'assume unchanged' (see
Junio C Hamano35738e82008-01-07 07:55:46144linkgit:git-update-index[1]).
Junio C Hamano7e9f6b72006-02-22 10:44:55145
Junio C Hamanod7105602017-11-21 05:32:50146-f::
147Similar to `-t`, but use lowercase letters for files
148that are marked as 'fsmonitor valid' (see
149linkgit:git-update-index[1]).
150
Junio C Hamano1a4e8412005-12-27 08:17:23151--full-name::
152When run from a subdirectory, the command usually
153outputs paths relative to the current directory. This
154option forces paths to be output relative to the project
155top directory.
156
Junio C Hamano4a401d52016-10-26 22:24:37157--recurse-submodules::
Junio C Hamano0dd50942020-04-29 21:21:05158Recursively calls ls-files on each active submodule in the repository.
Junio C Hamano4a401d52016-10-26 22:24:37159Currently there is only support for the --cached mode.
160
Junio C Hamano5c3957e2006-03-28 00:28:01161--abbrev[=<n>]::
162Instead of showing the full 40-byte hexadecimal object
Junio C Hamanoee43d182020-11-11 22:10:41163lines, show the shortest prefix that is at least '<n>'
164hexdigits long that uniquely refers the object.
Junio C Hamano5c3957e2006-03-28 00:28:01165Non default number of digits can be specified with --abbrev=<n>.
166
Junio C Hamanoa9788762010-08-03 15:15:54167--debug::
168After each line that describes a file, add more data about its
169cache entry. This is intended to show as much information as
170possible for manual inspection; the exact format may change at
171any time.
172
Junio C Hamanoffe10ca2016-02-04 00:44:23173--eol::
174Show <eolinfo> and <eolattr> of files.
175<eolinfo> is the file content identification used by Git when
176the "text" attribute is "auto" (or not set and core.autocrlf is not false).
177<eolinfo> is either "-text", "none", "lf", "crlf", "mixed" or "".
178+
179"" means the file is not a regular file, it is not in the index or
Junio C Hamano03a41f32016-03-04 22:22:15180not accessible in the working tree.
Junio C Hamanoffe10ca2016-02-04 00:44:23181+
182<eolattr> is the attribute that is used when checking out or committing,
183it is either "", "-text", "text", "text=auto", "text eol=lf", "text eol=crlf".
Junio C Hamanoe7808d72016-08-26 21:48:01184Since Git 2.10 "text=auto eol=lf" and "text=auto eol=crlf" are supported.
Junio C Hamanoffe10ca2016-02-04 00:44:23185+
186Both the <eolinfo> in the index ("i/<eolinfo>")
187and in the working tree ("w/<eolinfo>") are shown for regular files,
188followed by the ("attr/<eolattr>").
189
Junio C Hamano1bb569e2006-05-05 23:14:25190\--::
Junio C Hamano1a4e8412005-12-27 08:17:23191Do not interpret any more arguments as options.
192
193<file>::
194Files to show. If no files are given all files which match the other
195specified criteria are shown.
196
Junio C Hamanob9d9d902018-05-23 07:07:42197OUTPUT
Junio C Hamano1a4e8412005-12-27 08:17:23198------
Junio C Hamano92d80372016-07-13 22:00:05199'git ls-files' just outputs the filenames unless `--stage` is specified in
Junio C Hamano1a4e8412005-12-27 08:17:23200which case it outputs:
201
202 [<tag> ]<mode> <object> <stage> <file>
203
Junio C Hamanoffe10ca2016-02-04 00:44:23204'git ls-files --eol' will show
205i/<eolinfo><SPACES>w/<eolinfo><SPACES>attr/<eolattr><SPACE*><TAB><file>
206
Junio C Hamano1aa40d22010-01-21 17:46:43207'git ls-files --unmerged' and 'git ls-files --stage' can be used to examine
Junio C Hamano1a4e8412005-12-27 08:17:23208detailed information on unmerged paths.
209
Junio C Hamanoe3f080d2013-04-22 02:27:13210For an unmerged path, instead of recording a single mode/SHA-1 pair,
Junio C Hamano36460982007-05-27 04:29:12211the index records up to three such pairs; one from tree O in stage
Junio C Hamano1a4e8412005-12-27 08:17:232121, A in stage 2, and B in stage 3. This information can be used by
213the user (or the porcelain) to see what should eventually be recorded at the
Junio C Hamanofce7c7e2008-07-02 03:06:38214path. (see linkgit:git-read-tree[1] for more information on state)
Junio C Hamano1a4e8412005-12-27 08:17:23215
Junio C Hamano0f6f3bf2017-03-13 07:01:53216Without the `-z` option, pathnames with "unusual" characters are
217quoted as explained for the configuration variable `core.quotePath`
218(see linkgit:git-config[1]). Using `-z` the filename is output
219verbatim and the line is terminated by a NUL byte.
Junio C Hamano1a4e8412005-12-27 08:17:23220
221
Junio C Hamanob9d9d902018-05-23 07:07:42222EXCLUDE PATTERNS
Junio C Hamano1a4e8412005-12-27 08:17:23223----------------
224
Junio C Hamano1aa40d22010-01-21 17:46:43225'git ls-files' can use a list of "exclude patterns" when
Junio C Hamano1a4e8412005-12-27 08:17:23226traversing the directory tree and finding files to show when the
Junio C Hamano35738e82008-01-07 07:55:46227flags --others or --ignored are specified. linkgit:gitignore[5]
Junio C Hamano679d22d2007-06-02 21:13:44228specifies the format of exclude patterns.
Junio C Hamano1a4e8412005-12-27 08:17:23229
Junio C Hamano679d22d2007-06-02 21:13:44230These exclude patterns come from these places, in order:
Junio C Hamano1a4e8412005-12-27 08:17:23231
Junio C Hamanoe1aeb5e2014-06-06 19:16:29232 1. The command-line flag --exclude=<pattern> specifies a
Junio C Hamano679d22d2007-06-02 21:13:44233 single pattern. Patterns are ordered in the same order
234 they appear in the command line.
Junio C Hamano1a4e8412005-12-27 08:17:23235
Junio C Hamanoe1aeb5e2014-06-06 19:16:29236 2. The command-line flag --exclude-from=<file> specifies a
Junio C Hamano679d22d2007-06-02 21:13:44237 file containing a list of patterns. Patterns are ordered
238 in the same order they appear in the file.
Junio C Hamano1a4e8412005-12-27 08:17:23239
Junio C Hamanoe1aeb5e2014-06-06 19:16:29240 3. The command-line flag --exclude-per-directory=<name> specifies
Junio C Hamano1aa40d22010-01-21 17:46:43241 a name of the file in each directory 'git ls-files'
Junio C Hamano679d22d2007-06-02 21:13:44242 examines, normally `.gitignore`. Files in deeper
243 directories take precedence. Patterns are ordered in the
244 same order they appear in the files.
Junio C Hamano1a4e8412005-12-27 08:17:23245
246A pattern specified on the command line with --exclude or read
247from the file specified with --exclude-from is relative to the
248top of the directory tree. A pattern read from a file specified
249by --exclude-per-directory is relative to the directory that the
250pattern file appears in.
251
Junio C Hamano9049d912008-05-29 02:09:50252SEE ALSO
Junio C Hamano1a4e8412005-12-27 08:17:23253--------
Junio C Hamano35738e82008-01-07 07:55:46254linkgit:git-read-tree[1], linkgit:gitignore[5]
Junio C Hamano1a4e8412005-12-27 08:17:23255
Junio C Hamano1a4e8412005-12-27 08:17:23256GIT
257---
Junio C Hamanof7c042d2008-06-06 22:50:53258Part of the linkgit:git[1] suite