]> git.ipfire.org Git - thirdparty/git.git/blame - Documentation/git-ls-files.txt
ls-tree: add --abbrev[=<n>] option
[thirdparty/git.git] / Documentation / git-ls-files.txt
CommitLineData
2cf565c5
DG
1git-ls-files(1)
2===============
2cf565c5
DG
3
4NAME
5----
5f3aa197 6git-ls-files - Information about files in the index/working directory
2cf565c5
DG
7
8
9SYNOPSIS
10--------
f9666adf
JH
11[verse]
12'git-ls-files' [-z] [-t] [-v]
b0391890
JH
13 (--[cached|deleted|others|ignored|stage|unmerged|killed|modified])\*
14 (-[c|d|o|i|s|u|k|m])\*
2cf565c5
DG
15 [-x <pattern>|--exclude=<pattern>]
16 [-X <file>|--exclude-from=<file>]
9a84074d 17 [--exclude-per-directory=<file>]
c8af25ca 18 [--error-unmatch]
9a84074d 19 [--full-name] [--] [<file>]\*
2cf565c5
DG
20
21DESCRIPTION
22-----------
23This merges the file listing in the directory cache index with the
24actual working directory list, and shows different combinations of the
25two.
26
27One or more of the options below may be used to determine the files
28shown:
29
30OPTIONS
31-------
32-c|--cached::
33 Show cached files in the output (default)
34
35-d|--deleted::
36 Show deleted files in the output
37
b0391890
JH
38-m|--modified::
39 Show modified files in the output
40
2cf565c5
DG
41-o|--others::
42 Show other files in the output
43
44-i|--ignored::
45 Show ignored files in the output
46 Note the this also reverses any exclude list present.
47
48-s|--stage::
49 Show stage files in the output
50
a3259570
PB
51--directory::
52 If a whole directory is classified as "other", show just its
53 name (with a trailing slash) and not its whole contents.
54
2cf565c5
DG
55-u|--unmerged::
56 Show unmerged files in the output (forces --stage)
57
6ca45943
JH
58-k|--killed::
59 Show files on the filesystem that need to be removed due
ab182478 60 to file/directory conflicts for checkout-index to
6ca45943
JH
61 succeed.
62
2cf565c5 63-z::
d88156e9 64 \0 line termination on output.
2cf565c5
DG
65
66-x|--exclude=<pattern>::
67 Skips files matching pattern.
68 Note that pattern is a shell wildcard pattern.
69
70-X|--exclude-from=<file>::
71 exclude patterns are read from <file>; 1 per line.
30b0535f
JH
72
73--exclude-per-directory=<file>::
74 read additional exclude patterns that apply only to the
75 directory and its subdirectories in <file>.
2cf565c5 76
c8af25ca
CW
77--error-unmatch::
78 If any <file> does not appear in the index, treat this as an
79 error (return 1).
80
2cf565c5
DG
81-t::
82 Identify the file status with the following tags (followed by
83 a space) at the start of each line:
df8baa42
JF
84 H:: cached
85 M:: unmerged
86 R:: removed/deleted
89438677 87 C:: modified/changed
df8baa42 88 K:: to be killed
41ac06c7 89 ?:: other
2cf565c5 90
f9666adf
JH
91-v::
92 Similar to `-t`, but use lowercase letters for files
93 that are marked as 'always matching index'.
94
9a84074d
JH
95--full-name::
96 When run from a subdirectory, the command usually
97 outputs paths relative to the current directory. This
98 option forces paths to be output relative to the project
99 top directory.
100
500b97e4
FK
101--::
102 Do not interpret any more arguments as options.
103
104<file>::
105 Files to show. If no files are given all files which match the other
106 specified criteria are shown.
107
2cf565c5
DG
108Output
109------
110show files just outputs the filename unless '--stage' is specified in
111which case it outputs:
112
113 [<tag> ]<mode> <object> <stage> <file>
114
115"git-ls-files --unmerged" and "git-ls-files --stage" can be used to examine
116detailed information on unmerged paths.
117
118For an unmerged path, instead of recording a single mode/SHA1 pair,
119the dircache records up to three such pairs; one from tree O in stage
1201, A in stage 2, and B in stage 3. This information can be used by
2c6e4771 121the user (or the porcelain) to see what should eventually be recorded at the
baeda3a7 122path. (see git-read-tree for more information on state)
2cf565c5 123
d88156e9
JH
124When `-z` option is not used, TAB, LF, and backslash characters
125in pathnames are represented as `\t`, `\n`, and `\\`,
126respectively.
127
30b0535f
JH
128
129Exclude Patterns
130----------------
131
132'git-ls-files' can use a list of "exclude patterns" when
133traversing the directory tree and finding files to show when the
134flags --others or --ignored are specified.
135
136These exclude patterns come from these places:
137
df8baa42 138 1. command line flag --exclude=<pattern> specifies a single
30b0535f
JH
139 pattern.
140
df8baa42 141 2. command line flag --exclude-from=<file> specifies a list of
30b0535f
JH
142 patterns stored in a file.
143
df8baa42 144 3. command line flag --exclude-per-directory=<name> specifies
30b0535f
JH
145 a name of the file in each directory 'git-ls-files'
146 examines, and if exists, its contents are used as an
147 additional list of patterns.
148
149An exclude pattern file used by (2) and (3) contains one pattern
150per line. A line that starts with a '#' can be used as comment
151for readability.
152
1df092d2
JH
153There are three lists of patterns that are in effect at a given
154time. They are built and ordered in the following way:
30b0535f 155
1df092d2
JH
156 * --exclude=<pattern> from the command line; patterns are
157 ordered in the same order as they appear on the command line.
158
159 * lines read from --exclude-from=<file>; patterns are ordered
160 in the same order as they appear in the file.
30b0535f
JH
161
162 * When --exclude-per-directory=<name> is specified, upon
163 entering a directory that has such a file, its contents are
164 appended at the end of the current "list of patterns". They
165 are popped off when leaving the directory.
166
167Each pattern in the pattern list specifies "a match pattern" and
2c6e4771 168optionally the fate; either a file that matches the pattern is
1df092d2
JH
169considered excluded or included. A filename is matched against
170the patterns in the three lists; the --exclude-from list is
171checked first, then the --exclude-per-directory list, and then
172finally the --exclude list. The last match determines its fate.
173If there is no match in the three lists, the fate is "included".
30b0535f
JH
174
175A pattern specified on the command line with --exclude or read
176from the file specified with --exclude-from is relative to the
177top of the directory tree. A pattern read from a file specified
178by --exclude-per-directory is relative to the directory that the
179pattern file appears in.
180
181An exclude pattern is of the following format:
182
183 - an optional prefix '!' which means that the fate this pattern
184 specifies is "include", not the usual "exclude"; the
185 remainder of the pattern string is interpreted according to
186 the following rules.
187
188 - if it does not contain a slash '/', it is a shell glob
189 pattern and used to match against the filename without
190 leading directories (i.e. the same way as the current
191 implementation).
192
193 - otherwise, it is a shell glob pattern, suitable for
194 consumption by fnmatch(3) with FNM_PATHNAME flag. I.e. a
195 slash in the pattern must match a slash in the pathname.
df8baa42 196 "Documentation/\*.html" matches "Documentation/git.html" but
30b0535f
JH
197 not "ppc/ppc.html". As a natural exception, "/*.c" matches
198 "cat-file.c" but not "mozilla-sha1/sha1.c".
199
200An example:
201
df8baa42 202--------------------------------------------------------------
30b0535f
JH
203 $ cat .git/ignore
204 # ignore objects and archives, anywhere in the tree.
205 *.[oa]
206 $ cat Documentation/.gitignore
207 # ignore generated html files,
1df092d2 208 *.html
30b0535f
JH
209 # except foo.html which is maintained by hand
210 !foo.html
30b0535f
JH
211 $ git-ls-files --ignored \
212 --exclude='Documentation/*.[0-9]' \
213 --exclude-from=.git/ignore \
214 --exclude-per-directory=.gitignore
df8baa42 215--------------------------------------------------------------
30b0535f
JH
216
217
c1bdacf9
DG
218See Also
219--------
a7154e91 220gitlink:git-read-tree[1]
2cf565c5
DG
221
222
223Author
224------
225Written by Linus Torvalds <torvalds@osdl.org>
226
227Documentation
228--------------
229Documentation by David Greaves, Junio C Hamano and the git-list <git@vger.kernel.org>.
230
231GIT
232---
a7154e91 233Part of the gitlink:git[7] suite
2cf565c5 234