blob: 0dabf3f0ddc8d893818b3ce09436c1b5b1c72a33 [file] [log] [blame]
David Greaves2cf565c2005-05-10 22:32:30 +01001git-ls-files(1)
2===============
David Greaves2cf565c2005-05-10 22:32:30 +01003
4NAME
5----
Junio C Hamanoc3f0baa2007-01-18 15:53:37 -08006git-ls-files - Show information about files in the index and the working tree
David Greaves2cf565c2005-05-10 22:32:30 +01007
8
9SYNOPSIS
10--------
Junio C Hamanof9666ad2006-02-12 01:48:47 -080011[verse]
Ben Peart780494b2017-09-22 12:35:41 -040012'git ls-files' [-z] [-t] [-v] [-f]
Jean-Noël Avila89557d62021-11-06 19:48:53 +010013 [-c|--cached] [-d|--deleted] [-o|--others] [-i|--|ignored]
14 [-s|--stage] [-u|--unmerged] [-k|--|killed] [-m|--modified]
15 [--directory [--no-empty-directory]] [--eol]
ZheNing Hu93a7d982021-01-23 10:20:10 +000016 [--deduplicate]
David Greaves2cf565c2005-05-10 22:32:30 +010017 [-x <pattern>|--exclude=<pattern>]
18 [-X <file>|--exclude-from=<file>]
Eric Wongad0cae42006-03-07 11:59:17 -080019 [--exclude-per-directory=<file>]
Jeff King8e7b07c2007-11-15 02:04:30 -050020 [--exclude-standard]
Junio C Hamanoa7a0f3d2007-09-14 16:59:04 -070021 [--error-unmatch] [--with-tree=<tree-ish>]
Brandon Williamse77aa332016-10-07 11:18:49 -070022 [--full-name] [--recurse-submodules]
Junio C Hamanocda34e02020-11-04 14:01:37 -080023 [--abbrev[=<n>]] [--] [<file>...]
David Greaves2cf565c2005-05-10 22:32:30 +010024
25DESCRIPTION
26-----------
Utku Gultopub356d232021-01-08 16:54:56 +000027This merges the file listing in the index with the actual working
28directory list, and shows different combinations of the two.
David Greaves2cf565c2005-05-10 22:32:30 +010029
30One or more of the options below may be used to determine the files
31shown:
32
33OPTIONS
34-------
Stephan Beyer32402402008-06-08 03:36:09 +020035-c::
36--cached::
David Greaves2cf565c2005-05-10 22:32:30 +010037 Show cached files in the output (default)
38
Stephan Beyer32402402008-06-08 03:36:09 +020039-d::
40--deleted::
David Greaves2cf565c2005-05-10 22:32:30 +010041 Show deleted files in the output
42
Stephan Beyer32402402008-06-08 03:36:09 +020043-m::
44--modified::
Junio C Hamanob0391892005-09-19 15:11:15 -070045 Show modified files in the output
46
Stephan Beyer32402402008-06-08 03:36:09 +020047-o::
48--others::
Matthieu Moy4d590f02009-08-06 17:11:48 +020049 Show other (i.e. untracked) files in the output
David Greaves2cf565c2005-05-10 22:32:30 +010050
Stephan Beyer32402402008-06-08 03:36:09 +020051-i::
52--ignored::
Jeff King500348a2009-10-30 15:05:52 -040053 Show only ignored files in the output. When showing files in the
54 index, print only those matched by an exclude pattern. When
55 showing "other" files, show only those matched by an exclude
Andreas Heiduk47481ff2018-05-03 20:48:26 +020056 pattern. Standard ignore rules are not automatically activated,
57 therefore at least one of the `--exclude*` options is required.
David Greaves2cf565c2005-05-10 22:32:30 +010058
Stephan Beyer32402402008-06-08 03:36:09 +020059-s::
60--stage::
Mostyn Bramley-Moorebe6ed142017-04-01 09:08:25 +020061 Show staged contents' mode bits, object name and stage number in the output.
David Greaves2cf565c2005-05-10 22:32:30 +010062
Petr Baudisa3259572006-01-22 01:22:30 +010063--directory::
64 If a whole directory is classified as "other", show just its
65 name (with a trailing slash) and not its whole contents.
66
Petr Baudisb0a3de42006-03-26 16:59:52 +020067--no-empty-directory::
68 Do not list empty directories. Has no effect without --directory.
69
Stephan Beyer32402402008-06-08 03:36:09 +020070-u::
71--unmerged::
David Greaves2cf565c2005-05-10 22:32:30 +010072 Show unmerged files in the output (forces --stage)
73
Stephan Beyer32402402008-06-08 03:36:09 +020074-k::
75--killed::
Junio C Hamano6ca45942005-05-12 17:17:54 -070076 Show files on the filesystem that need to be removed due
Kai Ruemmlerab182472005-10-07 14:05:03 -070077 to file/directory conflicts for checkout-index to
Junio C Hamano6ca45942005-05-12 17:17:54 -070078 succeed.
79
David Greaves2cf565c2005-05-10 22:32:30 +010080-z::
Andreas Heiduk860cd692017-03-02 20:03:52 +010081 \0 line termination on output and do not quote filenames.
82 See OUTPUT below for more information.
David Greaves2cf565c2005-05-10 22:32:30 +010083
ZheNing Hu93a7d982021-01-23 10:20:10 +000084--deduplicate::
85 When only filenames are shown, suppress duplicates that may
86 come from having multiple stages during a merge, or giving
87 `--deleted` and `--modified` option at the same time.
88 When any of the `-t`, `--unmerged`, or `--stage` option is
89 in use, this option has no effect.
90
Stephan Beyer32402402008-06-08 03:36:09 +020091-x <pattern>::
92--exclude=<pattern>::
Junio C Hamano4c608522010-09-15 17:34:20 -070093 Skip untracked files matching pattern.
Jay Soffian75609a02010-09-15 19:56:48 -040094 Note that pattern is a shell wildcard pattern. See EXCLUDE PATTERNS
95 below for more information.
David Greaves2cf565c2005-05-10 22:32:30 +010096
Stephan Beyer32402402008-06-08 03:36:09 +020097-X <file>::
98--exclude-from=<file>::
Junio C Hamano4c608522010-09-15 17:34:20 -070099 Read exclude patterns from <file>; 1 per line.
Junio C Hamano30b05352005-07-24 15:47:26 -0700100
101--exclude-per-directory=<file>::
Junio C Hamano4c608522010-09-15 17:34:20 -0700102 Read additional exclude patterns that apply only to the
Junio C Hamano30b05352005-07-24 15:47:26 -0700103 directory and its subdirectories in <file>.
David Greaves2cf565c2005-05-10 22:32:30 +0100104
Jeff King8e7b07c2007-11-15 02:04:30 -0500105--exclude-standard::
Thomas Ackermann2de9b712013-01-21 20:17:53 +0100106 Add the standard Git exclusions: .git/info/exclude, .gitignore
Jeff King8e7b07c2007-11-15 02:04:30 -0500107 in each directory, and the user's global exclusion file.
108
Carl Worthc8af25c2006-02-21 12:48:30 -0800109--error-unmatch::
110 If any <file> does not appear in the index, treat this as an
111 error (return 1).
112
Junio C Hamanoa7a0f3d2007-09-14 16:59:04 -0700113--with-tree=<tree-ish>::
114 When using --error-unmatch to expand the user supplied
115 <file> (i.e. path pattern) arguments to paths, pretend
116 that paths which were removed in the index since the
117 named <tree-ish> are still present. Using this option
118 with `-s` or `-u` options does not make any sense.
119
David Greaves2cf565c2005-05-10 22:32:30 +0100120-t::
Matthieu Moy5bc0e242010-07-28 09:24:27 +0200121 This feature is semi-deprecated. For scripting purpose,
122 linkgit:git-status[1] `--porcelain` and
123 linkgit:git-diff-files[1] `--name-status` are almost always
124 superior alternatives, and users should look at
125 linkgit:git-status[1] `--short` or linkgit:git-diff[1]
126 `--name-status` for more user-friendly alternatives.
127+
Jeff Kingda9ca952019-04-22 11:15:41 -0400128--
Matthieu Moy5bc0e242010-07-28 09:24:27 +0200129This option identifies the file status with the following tags (followed by
130a space) at the start of each line:
131
Jonas Fonsecadf8baa42005-10-03 19:16:30 +0200132 H:: cached
Nguyễn Thái Ngọc Duy44a36912009-08-20 20:46:57 +0700133 S:: skip-worktree
Jonas Fonsecadf8baa42005-10-03 19:16:30 +0200134 M:: unmerged
135 R:: removed/deleted
Junio C Hamano89438672005-12-29 01:20:06 -0800136 C:: modified/changed
Jonas Fonsecadf8baa42005-10-03 19:16:30 +0200137 K:: to be killed
Junio C Hamano41ac06c2006-02-13 21:52:10 -0800138 ?:: other
Jeff Kingda9ca952019-04-22 11:15:41 -0400139--
David Greaves2cf565c2005-05-10 22:32:30 +0100140
Junio C Hamanof9666ad2006-02-12 01:48:47 -0800141-v::
142 Similar to `-t`, but use lowercase letters for files
Junio C Hamano56c3eb12007-12-21 13:50:58 -0800143 that are marked as 'assume unchanged' (see
Dan McGee5162e692007-12-29 00:20:38 -0600144 linkgit:git-update-index[1]).
Junio C Hamanof9666ad2006-02-12 01:48:47 -0800145
Ben Peart780494b2017-09-22 12:35:41 -0400146-f::
147 Similar to `-t`, but use lowercase letters for files
148 that are marked as 'fsmonitor valid' (see
149 linkgit:git-update-index[1]).
150
Junio C Hamano9a840742005-12-23 15:51:33 -0800151--full-name::
152 When run from a subdirectory, the command usually
153 outputs paths relative to the current directory. This
154 option forces paths to be output relative to the project
155 top directory.
156
Brandon Williamse77aa332016-10-07 11:18:49 -0700157--recurse-submodules::
Damien Robertacbfae32020-04-06 15:57:09 +0200158 Recursively calls ls-files on each active submodule in the repository.
Jonathan Tan290eada2022-02-23 16:23:03 -0800159 Currently there is only support for the --cached and --stage modes.
Brandon Williamse77aa332016-10-07 11:18:49 -0700160
Eric Wongad0cae42006-03-07 11:59:17 -0800161--abbrev[=<n>]::
162 Instead of showing the full 40-byte hexadecimal object
Junio C Hamanocda34e02020-11-04 14:01:37 -0800163 lines, show the shortest prefix that is at least '<n>'
164 hexdigits long that uniquely refers the object.
Eric Wongad0cae42006-03-07 11:59:17 -0800165 Non default number of digits can be specified with --abbrev=<n>.
166
Thomas Rast84974212010-07-31 00:35:59 +0200167--debug::
168 After each line that describes a file, add more data about its
169 cache entry. This is intended to show as much information as
170 possible for manual inspection; the exact format may change at
171 any time.
172
Torsten Bögershausena7630bd2016-01-16 07:50:02 +0100173--eol::
174 Show <eolinfo> and <eolattr> of files.
175 <eolinfo> is the file content identification used by Git when
176 the "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
Thomas Ackermannd285ab02016-03-03 19:43:51 +0100180not accessible in the working tree.
Torsten Bögershausena7630bd2016-01-16 07:50:02 +0100181+
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".
Torsten Bögershausen41a616d2016-08-25 17:52:57 +0200184Since Git 2.10 "text=auto eol=lf" and "text=auto eol=crlf" are supported.
Torsten Bögershausena7630bd2016-01-16 07:50:02 +0100185+
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
Derrick Stolee78087092021-12-22 14:20:53 +0000190--sparse::
191 If the index is sparse, show the sparse directories without expanding
192 to the contained files. Sparse directories will be shown with a
193 trailing slash, such as "x/" for a sparse directory "x".
194
seane9940042006-05-05 15:05:24 -0400195\--::
Fredrik Kuivinen500b97e2005-10-02 17:33:38 +0200196 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 other
200 specified criteria are shown.
201
Nguyễn Thái Ngọc Duy76a87882018-04-30 17:35:33 +0200202OUTPUT
David Greaves2cf565c2005-05-10 22:32:30 +0100203------
Matthieu Moybcf96262016-06-28 13:40:11 +0200204'git ls-files' just outputs the filenames unless `--stage` is specified in
David Greaves2cf565c2005-05-10 22:32:30 +0100205which case it outputs:
206
207 [<tag> ]<mode> <object> <stage> <file>
208
Torsten Bögershausena7630bd2016-01-16 07:50:02 +0100209'git ls-files --eol' will show
210 i/<eolinfo><SPACES>w/<eolinfo><SPACES>attr/<eolattr><SPACE*><TAB><file>
211
Thomas Rast0b444cd2010-01-10 00:33:00 +0100212'git ls-files --unmerged' and 'git ls-files --stage' can be used to examine
David Greaves2cf565c2005-05-10 22:32:30 +0100213detailed information on unmerged paths.
214
Thomas Ackermannd5fa1f12013-04-15 19:49:04 +0200215For an unmerged path, instead of recording a single mode/SHA-1 pair,
Jakub Narebski5adf3172007-05-26 00:37:40 +0200216the index records up to three such pairs; one from tree O in stage
David Greaves2cf565c2005-05-10 22:32:30 +01002171, A in stage 2, and B in stage 3. This information can be used by
Johannes Schindelin2c6e4772005-08-05 17:05:02 +0200218the user (or the porcelain) to see what should eventually be recorded at the
Jonathan Nieder483bc4f2008-06-30 13:56:34 -0500219path. (see linkgit:git-read-tree[1] for more information on state)
David Greaves2cf565c2005-05-10 22:32:30 +0100220
Andreas Heiduk860cd692017-03-02 20:03:52 +0100221Without the `-z` option, pathnames with "unusual" characters are
222quoted as explained for the configuration variable `core.quotePath`
223(see linkgit:git-config[1]). Using `-z` the filename is output
224verbatim and the line is terminated by a NUL byte.
Junio C Hamanod88156e2005-10-14 21:56:46 -0700225
Junio C Hamano30b05352005-07-24 15:47:26 -0700226
Nguyễn Thái Ngọc Duy76a87882018-04-30 17:35:33 +0200227EXCLUDE PATTERNS
Junio C Hamano30b05352005-07-24 15:47:26 -0700228----------------
229
Thomas Rast0b444cd2010-01-10 00:33:00 +0100230'git ls-files' can use a list of "exclude patterns" when
Junio C Hamano30b05352005-07-24 15:47:26 -0700231traversing the directory tree and finding files to show when the
Dan McGee5162e692007-12-29 00:20:38 -0600232flags --others or --ignored are specified. linkgit:gitignore[5]
Josh Triplettcedb8d52007-06-02 10:08:54 -0700233specifies the format of exclude patterns.
Junio C Hamano30b05352005-07-24 15:47:26 -0700234
Josh Triplettcedb8d52007-06-02 10:08:54 -0700235These exclude patterns come from these places, in order:
Junio C Hamano30b05352005-07-24 15:47:26 -0700236
Jason St. John06ab60c2014-05-21 14:52:26 -0400237 1. The command-line flag --exclude=<pattern> specifies a
Josh Triplettcedb8d52007-06-02 10:08:54 -0700238 single pattern. Patterns are ordered in the same order
239 they appear in the command line.
Junio C Hamano30b05352005-07-24 15:47:26 -0700240
Jason St. John06ab60c2014-05-21 14:52:26 -0400241 2. The command-line flag --exclude-from=<file> specifies a
Josh Triplettcedb8d52007-06-02 10:08:54 -0700242 file containing a list of patterns. Patterns are ordered
243 in the same order they appear in the file.
Junio C Hamano30b05352005-07-24 15:47:26 -0700244
Jason St. John06ab60c2014-05-21 14:52:26 -0400245 3. The command-line flag --exclude-per-directory=<name> specifies
Thomas Rast0b444cd2010-01-10 00:33:00 +0100246 a name of the file in each directory 'git ls-files'
Josh Triplettcedb8d52007-06-02 10:08:54 -0700247 examines, normally `.gitignore`. Files in deeper
248 directories take precedence. Patterns are ordered in the
249 same order they appear in the files.
Junio C Hamano30b05352005-07-24 15:47:26 -0700250
251A pattern specified on the command line with --exclude or read
252from the file specified with --exclude-from is relative to the
253top of the directory tree. A pattern read from a file specified
254by --exclude-per-directory is relative to the directory that the
255pattern file appears in.
256
Junio C Hamano56ae8df2008-05-28 16:55:27 -0700257SEE ALSO
David Greavesc1bdacf2005-05-10 22:32:38 +0100258--------
Dan McGee5162e692007-12-29 00:20:38 -0600259linkgit:git-read-tree[1], linkgit:gitignore[5]
David Greaves2cf565c2005-05-10 22:32:30 +0100260
David Greaves2cf565c2005-05-10 22:32:30 +0100261GIT
262---
Christian Couder9e1f0a82008-06-06 09:07:32 +0200263Part of the linkgit:git[1] suite