blob: 078b5566656010179475b8fab494e592725804a9 [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]
Jonathan Niederb1889c32008-06-30 01:09:04 -050012'git ls-files' [-z] [-t] [-v]
Jonathan Nieder12378c02010-08-20 05:31:58 -050013 (--[cached|deleted|others|ignored|stage|unmerged|killed|modified])*
14 (-[c|d|o|i|s|u|k|m])*
Torsten Bögershausena7630bd2016-01-16 07:50:02 +010015 [--eol]
David Greaves2cf565c2005-05-10 22:32:30 +010016 [-x <pattern>|--exclude=<pattern>]
17 [-X <file>|--exclude-from=<file>]
Eric Wongad0cae42006-03-07 11:59:17 -080018 [--exclude-per-directory=<file>]
Jeff King8e7b07c2007-11-15 02:04:30 -050019 [--exclude-standard]
Junio C Hamanoa7a0f3d2007-09-14 16:59:04 -070020 [--error-unmatch] [--with-tree=<tree-ish>]
Štěpán Němec0adda932010-10-08 19:31:17 +020021 [--full-name] [--abbrev] [--] [<file>...]
David Greaves2cf565c2005-05-10 22:32:30 +010022
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-------
Stephan Beyer32402402008-06-08 03:36:09 +020034-c::
35--cached::
David Greaves2cf565c2005-05-10 22:32:30 +010036 Show cached files in the output (default)
37
Stephan Beyer32402402008-06-08 03:36:09 +020038-d::
39--deleted::
David Greaves2cf565c2005-05-10 22:32:30 +010040 Show deleted files in the output
41
Stephan Beyer32402402008-06-08 03:36:09 +020042-m::
43--modified::
Junio C Hamanob0391892005-09-19 15:11:15 -070044 Show modified files in the output
45
Stephan Beyer32402402008-06-08 03:36:09 +020046-o::
47--others::
Matthieu Moy4d590f02009-08-06 17:11:48 +020048 Show other (i.e. untracked) files in the output
David Greaves2cf565c2005-05-10 22:32:30 +010049
Stephan Beyer32402402008-06-08 03:36:09 +020050-i::
51--ignored::
Jeff King500348a2009-10-30 15:05:52 -040052 Show only ignored files in the output. When showing files in the
53 index, print only those matched by an exclude pattern. When
54 showing "other" files, show only those matched by an exclude
55 pattern.
David Greaves2cf565c2005-05-10 22:32:30 +010056
Stephan Beyer32402402008-06-08 03:36:09 +020057-s::
58--stage::
Junio C Hamanoc2974322008-07-28 22:26:47 -070059 Show staged contents' object name, mode bits and stage number in the output.
David Greaves2cf565c2005-05-10 22:32:30 +010060
Petr Baudisa3259572006-01-22 01:22:30 +010061--directory::
62 If a whole directory is classified as "other", show just its
63 name (with a trailing slash) and not its whole contents.
64
Petr Baudisb0a3de42006-03-26 16:59:52 +020065--no-empty-directory::
66 Do not list empty directories. Has no effect without --directory.
67
Stephan Beyer32402402008-06-08 03:36:09 +020068-u::
69--unmerged::
David Greaves2cf565c2005-05-10 22:32:30 +010070 Show unmerged files in the output (forces --stage)
71
Stephan Beyer32402402008-06-08 03:36:09 +020072-k::
73--killed::
Junio C Hamano6ca45942005-05-12 17:17:54 -070074 Show files on the filesystem that need to be removed due
Kai Ruemmlerab182472005-10-07 14:05:03 -070075 to file/directory conflicts for checkout-index to
Junio C Hamano6ca45942005-05-12 17:17:54 -070076 succeed.
77
David Greaves2cf565c2005-05-10 22:32:30 +010078-z::
Junio C Hamanod88156e2005-10-14 21:56:46 -070079 \0 line termination on output.
David Greaves2cf565c2005-05-10 22:32:30 +010080
Stephan Beyer32402402008-06-08 03:36:09 +020081-x <pattern>::
82--exclude=<pattern>::
Junio C Hamano4c608522010-09-15 17:34:20 -070083 Skip untracked files matching pattern.
Jay Soffian75609a02010-09-15 19:56:48 -040084 Note that pattern is a shell wildcard pattern. See EXCLUDE PATTERNS
85 below for more information.
David Greaves2cf565c2005-05-10 22:32:30 +010086
Stephan Beyer32402402008-06-08 03:36:09 +020087-X <file>::
88--exclude-from=<file>::
Junio C Hamano4c608522010-09-15 17:34:20 -070089 Read exclude patterns from <file>; 1 per line.
Junio C Hamano30b05352005-07-24 15:47:26 -070090
91--exclude-per-directory=<file>::
Junio C Hamano4c608522010-09-15 17:34:20 -070092 Read additional exclude patterns that apply only to the
Junio C Hamano30b05352005-07-24 15:47:26 -070093 directory and its subdirectories in <file>.
David Greaves2cf565c2005-05-10 22:32:30 +010094
Jeff King8e7b07c2007-11-15 02:04:30 -050095--exclude-standard::
Thomas Ackermann2de9b712013-01-21 20:17:53 +010096 Add the standard Git exclusions: .git/info/exclude, .gitignore
Jeff King8e7b07c2007-11-15 02:04:30 -050097 in each directory, and the user's global exclusion file.
98
Carl Worthc8af25c2006-02-21 12:48:30 -080099--error-unmatch::
100 If any <file> does not appear in the index, treat this as an
101 error (return 1).
102
Junio C Hamanoa7a0f3d2007-09-14 16:59:04 -0700103--with-tree=<tree-ish>::
104 When using --error-unmatch to expand the user supplied
105 <file> (i.e. path pattern) arguments to paths, pretend
106 that paths which were removed in the index since the
107 named <tree-ish> are still present. Using this option
108 with `-s` or `-u` options does not make any sense.
109
David Greaves2cf565c2005-05-10 22:32:30 +0100110-t::
Matthieu Moy5bc0e242010-07-28 09:24:27 +0200111 This feature is semi-deprecated. For scripting purpose,
112 linkgit:git-status[1] `--porcelain` and
113 linkgit:git-diff-files[1] `--name-status` are almost always
114 superior alternatives, and users should look at
115 linkgit: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
Jonas Fonsecadf8baa42005-10-03 19:16:30 +0200121 H:: cached
Nguyễn Thái Ngọc Duy44a36912009-08-20 20:46:57 +0700122 S:: skip-worktree
Jonas Fonsecadf8baa42005-10-03 19:16:30 +0200123 M:: unmerged
124 R:: removed/deleted
Junio C Hamano89438672005-12-29 01:20:06 -0800125 C:: modified/changed
Jonas Fonsecadf8baa42005-10-03 19:16:30 +0200126 K:: to be killed
Junio C Hamano41ac06c2006-02-13 21:52:10 -0800127 ?:: other
David Greaves2cf565c2005-05-10 22:32:30 +0100128
Junio C Hamanof9666ad2006-02-12 01:48:47 -0800129-v::
130 Similar to `-t`, but use lowercase letters for files
Junio C Hamano56c3eb12007-12-21 13:50:58 -0800131 that are marked as 'assume unchanged' (see
Dan McGee5162e692007-12-29 00:20:38 -0600132 linkgit:git-update-index[1]).
Junio C Hamanof9666ad2006-02-12 01:48:47 -0800133
Junio C Hamano9a840742005-12-23 15:51:33 -0800134--full-name::
135 When run from a subdirectory, the command usually
136 outputs paths relative to the current directory. This
137 option forces paths to be output relative to the project
138 top directory.
139
Eric Wongad0cae42006-03-07 11:59:17 -0800140--abbrev[=<n>]::
141 Instead of showing the full 40-byte hexadecimal object
Jon Loeliger323b9db2009-01-12 14:02:07 -0600142 lines, show only a partial prefix.
Eric Wongad0cae42006-03-07 11:59:17 -0800143 Non default number of digits can be specified with --abbrev=<n>.
144
Thomas Rast84974212010-07-31 00:35:59 +0200145--debug::
146 After each line that describes a file, add more data about its
147 cache entry. This is intended to show as much information as
148 possible for manual inspection; the exact format may change at
149 any time.
150
Torsten Bögershausena7630bd2016-01-16 07:50:02 +0100151--eol::
152 Show <eolinfo> and <eolattr> of files.
153 <eolinfo> is the file content identification used by Git when
154 the "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
Thomas Ackermannd285ab02016-03-03 19:43:51 +0100158not accessible in the working tree.
Torsten Bögershausena7630bd2016-01-16 07:50:02 +0100159+
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
seane9940042006-05-05 15:05:24 -0400169\--::
Fredrik Kuivinen500b97e2005-10-02 17:33:38 +0200170 Do not interpret any more arguments as options.
171
172<file>::
173 Files to show. If no files are given all files which match the other
174 specified criteria are shown.
175
David Greaves2cf565c2005-05-10 22:32:30 +0100176Output
177------
Matthieu Moybcf96262016-06-28 13:40:11 +0200178'git ls-files' just outputs the filenames unless `--stage` is specified in
David Greaves2cf565c2005-05-10 22:32:30 +0100179which case it outputs:
180
181 [<tag> ]<mode> <object> <stage> <file>
182
Torsten Bögershausena7630bd2016-01-16 07:50:02 +0100183'git ls-files --eol' will show
184 i/<eolinfo><SPACES>w/<eolinfo><SPACES>attr/<eolattr><SPACE*><TAB><file>
185
Thomas Rast0b444cd2010-01-10 00:33:00 +0100186'git ls-files --unmerged' and 'git ls-files --stage' can be used to examine
David Greaves2cf565c2005-05-10 22:32:30 +0100187detailed information on unmerged paths.
188
Thomas Ackermannd5fa1f12013-04-15 19:49:04 +0200189For an unmerged path, instead of recording a single mode/SHA-1 pair,
Jakub Narebski5adf3172007-05-26 00:37:40 +0200190the index records up to three such pairs; one from tree O in stage
David Greaves2cf565c2005-05-10 22:32:30 +01001911, A in stage 2, and B in stage 3. This information can be used by
Johannes Schindelin2c6e4772005-08-05 17:05:02 +0200192the user (or the porcelain) to see what should eventually be recorded at the
Jonathan Nieder483bc4f2008-06-30 13:56:34 -0500193path. (see linkgit:git-read-tree[1] for more information on state)
David Greaves2cf565c2005-05-10 22:32:30 +0100194
Junio C Hamanod88156e2005-10-14 21:56:46 -0700195When `-z` option is not used, TAB, LF, and backslash characters
196in pathnames are represented as `\t`, `\n`, and `\\`,
197respectively.
198
Junio C Hamano30b05352005-07-24 15:47:26 -0700199
200Exclude Patterns
201----------------
202
Thomas Rast0b444cd2010-01-10 00:33:00 +0100203'git ls-files' can use a list of "exclude patterns" when
Junio C Hamano30b05352005-07-24 15:47:26 -0700204traversing the directory tree and finding files to show when the
Dan McGee5162e692007-12-29 00:20:38 -0600205flags --others or --ignored are specified. linkgit:gitignore[5]
Josh Triplettcedb8d52007-06-02 10:08:54 -0700206specifies the format of exclude patterns.
Junio C Hamano30b05352005-07-24 15:47:26 -0700207
Josh Triplettcedb8d52007-06-02 10:08:54 -0700208These exclude patterns come from these places, in order:
Junio C Hamano30b05352005-07-24 15:47:26 -0700209
Jason St. John06ab60c2014-05-21 14:52:26 -0400210 1. The command-line flag --exclude=<pattern> specifies a
Josh Triplettcedb8d52007-06-02 10:08:54 -0700211 single pattern. Patterns are ordered in the same order
212 they appear in the command line.
Junio C Hamano30b05352005-07-24 15:47:26 -0700213
Jason St. John06ab60c2014-05-21 14:52:26 -0400214 2. The command-line flag --exclude-from=<file> specifies a
Josh Triplettcedb8d52007-06-02 10:08:54 -0700215 file containing a list of patterns. Patterns are ordered
216 in the same order they appear in the file.
Junio C Hamano30b05352005-07-24 15:47:26 -0700217
Jason St. John06ab60c2014-05-21 14:52:26 -0400218 3. The command-line flag --exclude-per-directory=<name> specifies
Thomas Rast0b444cd2010-01-10 00:33:00 +0100219 a name of the file in each directory 'git ls-files'
Josh Triplettcedb8d52007-06-02 10:08:54 -0700220 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 Hamano30b05352005-07-24 15:47:26 -0700223
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 Hamano56ae8df2008-05-28 16:55:27 -0700230SEE ALSO
David Greavesc1bdacf2005-05-10 22:32:38 +0100231--------
Dan McGee5162e692007-12-29 00:20:38 -0600232linkgit:git-read-tree[1], linkgit:gitignore[5]
David Greaves2cf565c2005-05-10 22:32:30 +0100233
David Greaves2cf565c2005-05-10 22:32:30 +0100234GIT
235---
Christian Couder9e1f0a82008-06-06 09:07:32 +0200236Part of the linkgit:git[1] suite