2 .\" Title: git-ls-files
3 .\" Author: [FIXME: author] [see http://www.docbook.org/tdg5/en/html/author]
4 .\" Generator: DocBook XSL Stylesheets v1.79.2 <http://docbook.sf.net/>
7 .\" Source: Git 2.47.0.rc1.33.g90fe3800b9
10 .TH "GIT\-LS\-FILES" "1" "2024-10-04" "Git 2\&.47\&.0\&.rc1\&.33\&.g9" "Git Manual"
11 .\" -----------------------------------------------------------------
12 .\" * Define some portability stuff
13 .\" -----------------------------------------------------------------
14 .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
15 .\" http://bugs.debian.org/507673
16 .\" http://lists.gnu.org/archive/html/groff/2009-02/msg00013.html
17 .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
20 .\" -----------------------------------------------------------------
21 .\" * set default formatting
22 .\" -----------------------------------------------------------------
23 .\" disable hyphenation
25 .\" disable justification (adjust text to left margin only)
27 .\" -----------------------------------------------------------------
28 .\" * MAIN CONTENT STARTS HERE *
29 .\" -----------------------------------------------------------------
31 git-ls-files \- Show information about files in the index and the working tree
35 \fIgit ls\-files\fR [\-z] [\-t] [\-v] [\-f]
36 [\-c|\-\-cached] [\-d|\-\-deleted] [\-o|\-\-others] [\-i|\-\-ignored]
37 [\-s|\-\-stage] [\-u|\-\-unmerged] [\-k|\-\-killed] [\-m|\-\-modified]
39 [\-\-directory [\-\-no\-empty\-directory]] [\-\-eol]
41 [\-x <pattern>|\-\-exclude=<pattern>]
42 [\-X <file>|\-\-exclude\-from=<file>]
43 [\-\-exclude\-per\-directory=<file>]
44 [\-\-exclude\-standard]
45 [\-\-error\-unmatch] [\-\-with\-tree=<tree\-ish>]
46 [\-\-full\-name] [\-\-recurse\-submodules]
47 [\-\-abbrev[=<n>]] [\-\-format=<format>] [\-\-] [<file>\&...\:]
51 This command merges the file listing in the index with the actual working directory list, and shows different combinations of the two\&.
53 Several flags can be used to determine which files are shown, and each file may be printed multiple times if there are multiple entries in the index or if multiple statuses are applicable for the relevant file selection options\&.
58 Show all files cached in Git\(cqs index, i\&.e\&. all tracked files\&. (This is the default if no \-c/\-s/\-d/\-o/\-u/\-k/\-m/\-\-resolve\-undo options are specified\&.)
63 Show files with an unstaged deletion
68 Show files with an unstaged modification (note that an unstaged deletion also counts as an unstaged modification)
73 Show other (i\&.e\&. untracked) files in the output
78 Show only ignored files in the output\&. Must be used with either an explicit
81 \fI\-o\fR\&. When showing files in the index (i\&.e\&. when used with
82 \fI\-c\fR), print only those files matching an exclude pattern\&. When showing "other" files (i\&.e\&. when used with
83 \fI\-o\fR), show only those matched by an exclude pattern\&. Standard ignore rules are not automatically activated; therefore, at least one of the
85 options is required\&.
90 Show staged contents\*(Aq mode bits, object name and stage number in the output\&.
95 If a whole directory is classified as "other", show just its name (with a trailing slash) and not its whole contents\&. Has no effect without \-o/\-\-others\&.
98 \-\-no\-empty\-directory
100 Do not list empty directories\&. Has no effect without \-\-directory\&.
105 Show information about unmerged files in the output, but do not show any other tracked files (forces \-\-stage, overrides \-\-cached)\&.
110 Show untracked files on the filesystem that need to be removed due to file/directory conflicts for tracked files to be able to be written to the filesystem\&.
115 Show files having resolve\-undo information in the index together with their resolve\-undo information\&. (resolve\-undo information is what is used to implement "git checkout \-m $PATH", i\&.e\&. to recreate merge conflicts that were accidentally resolved)
120 \e0 line termination on output and do not quote filenames\&. See OUTPUT below for more information\&.
125 When only filenames are shown, suppress duplicates that may come from having multiple stages during a merge, or giving
129 option at the same time\&. When any of the
131 \fB\-\-unmerged\fR, or
133 option is in use, this option has no effect\&.
136 \-x <pattern>, \-\-exclude=<pattern>
138 Skip untracked files matching pattern\&. Note that pattern is a shell wildcard pattern\&. See EXCLUDE PATTERNS below for more information\&.
141 \-X <file>, \-\-exclude\-from=<file>
143 Read exclude patterns from <file>; 1 per line\&.
146 \-\-exclude\-per\-directory=<file>
148 Read additional exclude patterns that apply only to the directory and its subdirectories in <file>\&. If you are trying to emulate the way Porcelain commands work, using the
149 \fB\-\-exclude\-standard\fR
150 option instead is easier and more thorough\&.
153 \-\-exclude\-standard
155 Add the standard Git exclusions: \&.git/info/exclude, \&.gitignore in each directory, and the user\(cqs global exclusion file\&.
160 If any <file> does not appear in the index, treat this as an error (return 1)\&.
163 \-\-with\-tree=<tree\-ish>
165 When using \-\-error\-unmatch to expand the user supplied <file> (i\&.e\&. path pattern) arguments to paths, pretend that paths which were removed in the index since the named <tree\-ish> are still present\&. Using this option with
169 options does not make any sense\&.
174 Show status tags together with filenames\&. Note that for scripting purposes,
178 \fBgit-diff-files\fR(1)
179 \fB\-\-name\-status\fR
180 are almost always superior alternatives; users should look at
185 \fB\-\-name\-status\fR
186 for more user\-friendly alternatives\&.
188 This option provides a reason for showing each filename, in the form of a status tag (which is followed by a space and then the filename)\&. The status tags are all single characters from the following list:
192 tracked file that is not either unmerged or skip\-worktree
197 tracked file that is skip\-worktree
202 tracked file that is unmerged
207 tracked file with unstaged removal/deletion
212 tracked file with unstaged modification/change
217 untracked paths which are part of file/directory conflicts which prevent checking out tracked files
227 file with resolve\-undo information
234 \fB\-t\fR, but use lowercase letters for files that are marked as
235 \fIassume unchanged\fR
237 \fBgit-update-index\fR(1))\&.
243 \fB\-t\fR, but use lowercase letters for files that are marked as
244 \fIfsmonitor valid\fR
246 \fBgit-update-index\fR(1))\&.
251 When run from a subdirectory, the command usually outputs paths relative to the current directory\&. This option forces paths to be output relative to the project top directory\&.
254 \-\-recurse\-submodules
256 Recursively calls ls\-files on each active submodule in the repository\&. Currently there is only support for the \-\-cached and \-\-stage modes\&.
261 Instead of showing the full 40\-byte hexadecimal object lines, show the shortest prefix that is at least
263 hexdigits long that uniquely refers the object\&. Non default number of digits can be specified with \-\-abbrev=<n>\&.
268 After each line that describes a file, add more data about its cache entry\&. This is intended to show as much information as possible for manual inspection; the exact format may change at any time\&.
273 Show <eolinfo> and <eolattr> of files\&. <eolinfo> is the file content identification used by Git when the "text" attribute is "auto" (or not set and core\&.autocrlf is not false)\&. <eolinfo> is either "\-text", "none", "lf", "crlf", "mixed" or ""\&.
275 "" means the file is not a regular file, it is not in the index or not accessible in the working tree\&.
277 <eolattr> is the attribute that is used when checking out or committing, it is either "", "\-text", "text", "text=auto", "text eol=lf", "text eol=crlf"\&. Since Git 2\&.10 "text=auto eol=lf" and "text=auto eol=crlf" are supported\&.
279 Both the <eolinfo> in the index ("i/<eolinfo>") and in the working tree ("w/<eolinfo>") are shown for regular files, followed by the ("attr/<eolattr>")\&.
284 If the index is sparse, show the sparse directories without expanding to the contained files\&. Sparse directories will be shown with a trailing slash, such as "x/" for a sparse directory "x"\&.
289 A string that interpolates
291 from the result being shown\&. It also interpolates
298 are hex digits interpolates to character with hex code
299 \fBXX\fR; for example
309 (LF)\&. \-\-format cannot be combined with
314 \fB\-\-resolve\-undo\fR
321 Do not interpret any more arguments as options\&.
326 Files to show\&. If no files are given all files which match the other specified criteria are shown\&.
330 \fIgit ls\-files\fR just outputs the filenames unless \fB\-\-stage\fR is specified in which case it outputs:
336 [<tag> ]<mode> <object> <stage> <file>
342 \fIgit ls\-files \-\-eol\fR will show i/<eolinfo><SPACES>w/<eolinfo><SPACES>attr/<eolattr><SPACE*><TAB><file>
344 \fIgit ls\-files \-\-unmerged\fR and \fIgit ls\-files \-\-stage\fR can be used to examine detailed information on unmerged paths\&.
346 For an unmerged path, instead of recording a single mode/SHA\-1 pair, the index records up to three such pairs; one from tree O in stage 1, A in stage 2, and B in stage 3\&. This information can be used by the user (or the porcelain) to see what should eventually be recorded at the path\&. (see \fBgit-read-tree\fR(1) for more information on state)
348 Without the \fB\-z\fR option, pathnames with "unusual" characters are quoted as explained for the configuration variable \fBcore\&.quotePath\fR (see \fBgit-config\fR(1))\&. Using \fB\-z\fR the filename is output verbatim and the line is terminated by a NUL byte\&.
350 It is possible to print in a custom format by using the \fB\-\-format\fR option, which is able to interpolate different fields using a \fB%(fieldname)\fR notation\&. For example, if you only care about the "objectname" and "path" fields, you can execute with a specific "\-\-format" like
356 git ls\-files \-\-format=\*(Aq%(objectname) %(path)\*(Aq
363 The way each path is shown can be customized by using the \fB\-\-format=<format>\fR option, where the %(fieldname) in the <format> string for various aspects of the index entry are interpolated\&. The following "fieldname" are understood:
367 The mode of the file which is recorded in the index\&.
372 The object type of the file which is recorded in the index\&.
377 The name of the file which is recorded in the index\&.
382 The object size of the file which is recorded in the index ("\-" if the object is a
385 \fBtree\fR)\&. It also supports a padded format of size with "%(objectsize:padded)"\&.
390 The stage of the file which is recorded in the index\&.
393 eolinfo:index, eolinfo:worktree
395 The <eolinfo> (see the description of the
397 option) of the contents in the index or in the worktree for the path\&.
402 The <eolattr> (see the description of the
404 option) that applies to the path\&.
409 The pathname of the file which is recorded in the index\&.
411 .SH "EXCLUDE PATTERNS"
413 \fIgit ls\-files\fR can use a list of "exclude patterns" when traversing the directory tree and finding files to show when the flags \-\-others or \-\-ignored are specified\&. \fBgitignore\fR(5) specifies the format of exclude patterns\&.
415 These exclude patterns can be specified from the following places, in order:
425 The command\-line flag \-\-exclude=<pattern> specifies a single pattern\&. Patterns are ordered in the same order they appear in the command line\&.
436 The command\-line flag \-\-exclude\-from=<file> specifies a file containing a list of patterns\&. Patterns are ordered in the same order they appear in the file\&.
447 The command\-line flag \-\-exclude\-per\-directory=<name> specifies a name of the file in each directory
450 \fB\&.gitignore\fR\&. Files in deeper directories take precedence\&. Patterns are ordered in the same order they appear in the files\&.
453 A pattern specified on the command line with \-\-exclude or read from the file specified with \-\-exclude\-from is relative to the top of the directory tree\&. A pattern read from a file specified by \-\-exclude\-per\-directory is relative to the directory that the pattern file appears in\&.
455 Generally, you should be able to use \fB\-\-exclude\-standard\fR when you want the exclude rules applied the same way as what Porcelain commands do\&. To emulate what \fB\-\-exclude\-standard\fR specifies, you can give \fB\-\-exclude\-per\-directory=\&.gitignore\fR, and then specify:
465 The file specified by the
466 \fBcore\&.excludesfile\fR
467 configuration variable, if exists, or the
468 \fB$XDG_CONFIG_HOME/git/ignore\fR
481 \fB$GIT_DIR/info/exclude\fR
485 via the \fB\-\-exclude\-from=\fR option\&.
488 \fBgit-read-tree\fR(1), \fBgitignore\fR(5)
491 Part of the \fBgit\fR(1) suite