blob: 75c3f4157d845876a91f04f955878a3affc9bd6e [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 Hamanofce7c7e2008-07-02 03:06:3812'git ls-files' [-z] [-t] [-v]
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 Hamano1a4e8412005-12-27 08:17:2316[-x <pattern>|--exclude=<pattern>]
17[-X <file>|--exclude-from=<file>]
Junio C Hamano5c3957e2006-03-28 00:28:0118[--exclude-per-directory=<file>]
Junio C Hamanoff979792007-11-16 10:11:3019[--exclude-standard]
Junio C Hamano58155b42007-09-15 07:46:1420[--error-unmatch] [--with-tree=<tree-ish>]
Junio C Hamanod2179ef2010-10-22 04:12:1721[--full-name] [--abbrev] [--] [<file>...]
Junio C Hamano1a4e8412005-12-27 08:17:2322
23DESCRIPTION
24-----------
25This merges the file listing in the directory cache index with the
26actual working directory list, and shows different combinations of the
27two.
28
29One or more of the options below may be used to determine the files
30shown:
31
32OPTIONS
33-------
Junio C Hamanoeb415992008-06-08 22:49:4734-c::
35--cached::
Junio C Hamano1a4e8412005-12-27 08:17:2336Show cached files in the output (default)
37
Junio C Hamanoeb415992008-06-08 22:49:4738-d::
39--deleted::
Junio C Hamano1a4e8412005-12-27 08:17:2340Show deleted files in the output
41
Junio C Hamanoeb415992008-06-08 22:49:4742-m::
43--modified::
Junio C Hamano1a4e8412005-12-27 08:17:2344Show modified files in the output
45
Junio C Hamanoeb415992008-06-08 22:49:4746-o::
47--others::
Junio C Hamano31cca162009-08-07 05:40:0148Show other (i.e. untracked) files in the output
Junio C Hamano1a4e8412005-12-27 08:17:2349
Junio C Hamanoeb415992008-06-08 22:49:4750-i::
51--ignored::
Junio C Hamano446ed772009-11-10 22:02:2052Show only ignored files in the output. When showing files in the
53index, print only those matched by an exclude pattern. When
54showing "other" files, show only those matched by an exclude
55pattern.
Junio C Hamano1a4e8412005-12-27 08:17:2356
Junio C Hamanoeb415992008-06-08 22:49:4757-s::
58--stage::
Junio C Hamano90ccff32008-07-29 08:17:2459Show staged contents' object name, mode bits and stage number in the output.
Junio C Hamano1a4e8412005-12-27 08:17:2360
Junio C Hamanoa6331a82006-01-22 07:50:3361--directory::
62If a whole directory is classified as "other", show just its
63name (with a trailing slash) and not its whole contents.
64
Junio C Hamanof02e09f2006-03-27 07:51:0365--no-empty-directory::
66Do not list empty directories. Has no effect without --directory.
67
Junio C Hamanoeb415992008-06-08 22:49:4768-u::
69--unmerged::
Junio C Hamano1a4e8412005-12-27 08:17:2370Show unmerged files in the output (forces --stage)
71
Junio C Hamanoeb415992008-06-08 22:49:4772-k::
73--killed::
Junio C Hamano1a4e8412005-12-27 08:17:2374Show files on the filesystem that need to be removed due
75to file/directory conflicts for checkout-index to
76succeed.
77
78-z::
79\0 line termination on output.
80
Junio C Hamanoeb415992008-06-08 22:49:4781-x <pattern>::
82--exclude=<pattern>::
Junio C Hamanoac752fa2010-09-19 00:01:0083Skip untracked files matching pattern.
84Note that pattern is a shell wildcard pattern. See EXCLUDE PATTERNS
85below for more information.
Junio C Hamano1a4e8412005-12-27 08:17:2386
Junio C Hamanoeb415992008-06-08 22:49:4787-X <file>::
88--exclude-from=<file>::
Junio C Hamanoac752fa2010-09-19 00:01:0089Read exclude patterns from <file>; 1 per line.
Junio C Hamano1a4e8412005-12-27 08:17:2390
91--exclude-per-directory=<file>::
Junio C Hamanoac752fa2010-09-19 00:01:0092Read additional exclude patterns that apply only to the
Junio C Hamano1a4e8412005-12-27 08:17:2393directory and its subdirectories in <file>.
94
Junio C Hamanoff979792007-11-16 10:11:3095--exclude-standard::
Junio C Hamano076ffcc2013-02-06 05:13:2196Add the standard Git exclusions: .git/info/exclude, .gitignore
Junio C Hamanoff979792007-11-16 10:11:3097in each directory, and the user's global exclusion file.
98
Junio C Hamano7e9f6b72006-02-22 10:44:5599--error-unmatch::
100If any <file> does not appear in the index, treat this as an
101error (return 1).
102
Junio C Hamano58155b42007-09-15 07:46:14103--with-tree=<tree-ish>::
104When using --error-unmatch to expand the user supplied
105<file> (i.e. path pattern) arguments to paths, pretend
106that paths which were removed in the index since the
107named <tree-ish> are still present. Using this option
108with `-s` or `-u` options does not make any sense.
109
Junio C Hamano1a4e8412005-12-27 08:17:23110-t::
Junio C Hamanoa9788762010-08-03 15:15:54111This feature is semi-deprecated. For scripting purpose,
112linkgit:git-status[1] `--porcelain` and
113linkgit:git-diff-files[1] `--name-status` are almost always
114superior alternatives, and users should look at
115linkgit:git-status[1] `--short` or linkgit:git-diff[1]
116`--name-status` for more user-friendly alternatives.
117+
118This option identifies the file status with the following tags (followed by
119a space) at the start of each line:
120
Junio C Hamano1a4e8412005-12-27 08:17:23121H:: cached
Junio C Hamano3c8d6702010-01-13 23:09:03122S:: skip-worktree
Junio C Hamano1a4e8412005-12-27 08:17:23123M:: unmerged
124R:: removed/deleted
Junio C Hamano235a91e2006-01-07 01:13:58125C:: modified/changed
Junio C Hamano1a4e8412005-12-27 08:17:23126K:: to be killed
Junio C Hamano6697ac52006-02-14 08:00:23127?:: other
Junio C Hamano1a4e8412005-12-27 08:17:23128
Junio C Hamano7e9f6b72006-02-22 10:44:55129-v::
130Similar to `-t`, but use lowercase letters for files
Junio C Hamanof556fc22007-12-23 08:16:38131that are marked as 'assume unchanged' (see
Junio C Hamano35738e82008-01-07 07:55:46132linkgit:git-update-index[1]).
Junio C Hamano7e9f6b72006-02-22 10:44:55133
Junio C Hamano1a4e8412005-12-27 08:17:23134--full-name::
135When run from a subdirectory, the command usually
136outputs paths relative to the current directory. This
137option forces paths to be output relative to the project
138top directory.
139
Junio C Hamano5c3957e2006-03-28 00:28:01140--abbrev[=<n>]::
141Instead of showing the full 40-byte hexadecimal object
Junio C Hamano6efe3022009-01-13 16:47:56142lines, show only a partial prefix.
Junio C Hamano5c3957e2006-03-28 00:28:01143Non default number of digits can be specified with --abbrev=<n>.
144
Junio C Hamanoa9788762010-08-03 15:15:54145--debug::
146After each line that describes a file, add more data about its
147cache entry. This is intended to show as much information as
148possible for manual inspection; the exact format may change at
149any time.
150
Junio C Hamanoffe10ca2016-02-04 00:44:23151--eol::
152Show <eolinfo> and <eolattr> of files.
153<eolinfo> is the file content identification used by Git when
154the "text" attribute is "auto" (or not set and core.autocrlf is not false).
155<eolinfo> is either "-text", "none", "lf", "crlf", "mixed" or "".
156+
157"" means the file is not a regular file, it is not in the index or
Junio C Hamano03a41f32016-03-04 22:22:15158not accessible in the working tree.
Junio C Hamanoffe10ca2016-02-04 00:44:23159+
160<eolattr> is the attribute that is used when checking out or committing,
161it is either "", "-text", "text", "text=auto", "text eol=lf", "text eol=crlf".
162Note: Currently Git does not support "text=auto eol=lf" or "text=auto eol=crlf",
163that may change in the future.
164+
165Both the <eolinfo> in the index ("i/<eolinfo>")
166and in the working tree ("w/<eolinfo>") are shown for regular files,
167followed by the ("attr/<eolattr>").
168
Junio C Hamano1bb569e2006-05-05 23:14:25169\--::
Junio C Hamano1a4e8412005-12-27 08:17:23170Do not interpret any more arguments as options.
171
172<file>::
173Files to show. If no files are given all files which match the other
174specified criteria are shown.
175
176Output
177------
Junio C Hamanod0d892c2010-01-24 20:06:29178'git ls-files' just outputs the filenames unless '--stage' is specified in
Junio C Hamano1a4e8412005-12-27 08:17:23179which case it outputs:
180
181 [<tag> ]<mode> <object> <stage> <file>
182
Junio C Hamanoffe10ca2016-02-04 00:44:23183'git ls-files --eol' will show
184i/<eolinfo><SPACES>w/<eolinfo><SPACES>attr/<eolattr><SPACE*><TAB><file>
185
Junio C Hamano1aa40d22010-01-21 17:46:43186'git ls-files --unmerged' and 'git ls-files --stage' can be used to examine
Junio C Hamano1a4e8412005-12-27 08:17:23187detailed information on unmerged paths.
188
Junio C Hamanoe3f080d2013-04-22 02:27:13189For an unmerged path, instead of recording a single mode/SHA-1 pair,
Junio C Hamano36460982007-05-27 04:29:12190the index records up to three such pairs; one from tree O in stage
Junio C Hamano1a4e8412005-12-27 08:17:231911, A in stage 2, and B in stage 3. This information can be used by
192the user (or the porcelain) to see what should eventually be recorded at the
Junio C Hamanofce7c7e2008-07-02 03:06:38193path. (see linkgit:git-read-tree[1] for more information on state)
Junio C Hamano1a4e8412005-12-27 08:17:23194
195When `-z` option is not used, TAB, LF, and backslash characters
196in pathnames are represented as `\t`, `\n`, and `\\`,
197respectively.
198
199
200Exclude Patterns
201----------------
202
Junio C Hamano1aa40d22010-01-21 17:46:43203'git ls-files' can use a list of "exclude patterns" when
Junio C Hamano1a4e8412005-12-27 08:17:23204traversing the directory tree and finding files to show when the
Junio C Hamano35738e82008-01-07 07:55:46205flags --others or --ignored are specified. linkgit:gitignore[5]
Junio C Hamano679d22d2007-06-02 21:13:44206specifies the format of exclude patterns.
Junio C Hamano1a4e8412005-12-27 08:17:23207
Junio C Hamano679d22d2007-06-02 21:13:44208These exclude patterns come from these places, in order:
Junio C Hamano1a4e8412005-12-27 08:17:23209
Junio C Hamanoe1aeb5e2014-06-06 19:16:29210 1. The command-line flag --exclude=<pattern> specifies a
Junio C Hamano679d22d2007-06-02 21:13:44211 single pattern. Patterns are ordered in the same order
212 they appear in the command line.
Junio C Hamano1a4e8412005-12-27 08:17:23213
Junio C Hamanoe1aeb5e2014-06-06 19:16:29214 2. The command-line flag --exclude-from=<file> specifies a
Junio C Hamano679d22d2007-06-02 21:13:44215 file containing a list of patterns. Patterns are ordered
216 in the same order they appear in the file.
Junio C Hamano1a4e8412005-12-27 08:17:23217
Junio C Hamanoe1aeb5e2014-06-06 19:16:29218 3. The command-line flag --exclude-per-directory=<name> specifies
Junio C Hamano1aa40d22010-01-21 17:46:43219 a name of the file in each directory 'git ls-files'
Junio C Hamano679d22d2007-06-02 21:13:44220 examines, normally `.gitignore`. Files in deeper
221 directories take precedence. Patterns are ordered in the
222 same order they appear in the files.
Junio C Hamano1a4e8412005-12-27 08:17:23223
224A pattern specified on the command line with --exclude or read
225from the file specified with --exclude-from is relative to the
226top of the directory tree. A pattern read from a file specified
227by --exclude-per-directory is relative to the directory that the
228pattern file appears in.
229
Junio C Hamano9049d912008-05-29 02:09:50230SEE ALSO
Junio C Hamano1a4e8412005-12-27 08:17:23231--------
Junio C Hamano35738e82008-01-07 07:55:46232linkgit:git-read-tree[1], linkgit:gitignore[5]
Junio C Hamano1a4e8412005-12-27 08:17:23233
Junio C Hamano1a4e8412005-12-27 08:17:23234GIT
235---
Junio C Hamanof7c042d2008-06-06 22:50:53236Part of the linkgit:git[1] suite