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