man-pages/man1/git-ls-files.1.html
2021-03-31 01:06:50 +01:00

428 lines
11 KiB
HTML

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<HTML><HEAD><TITLE>Man page of GIT-LS-FILES</TITLE>
</HEAD><BODY>
<H1>GIT-LS-FILES</H1>
Section: Git Manual (1)<BR>Updated: 03/04/2021<BR><A HREF="#index">Index</A>
<A HREF="/cgi-bin/man/man2html">Return to Main Contents</A><HR>
<A NAME="lbAB">&nbsp;</A>
<H2>NAME</H2>
git-ls-files - Show information about files in the index and the working tree
<A NAME="lbAC">&nbsp;</A>
<H2>SYNOPSIS</H2>
<P>
<PRE>
<I>git ls-files</I> [-z] [-t] [-v] [-f]
(--[cached|deleted|others|ignored|stage|unmerged|killed|modified])*
(-[c|d|o|i|s|u|k|m])*
[--eol]
[-x &lt;pattern&gt;|--exclude=&lt;pattern&gt;]
[-X &lt;file&gt;|--exclude-from=&lt;file&gt;]
[--exclude-per-directory=&lt;file&gt;]
[--exclude-standard]
[--error-unmatch] [--with-tree=&lt;tree-ish&gt;]
[--full-name] [--recurse-submodules]
[--abbrev] [--] [&lt;file&gt;...]
</PRE>
<P>
<A NAME="lbAD">&nbsp;</A>
<H2>DESCRIPTION</H2>
<P>
This merges the file listing in the directory cache index with the actual working directory list, and shows different combinations of the two.
<P>
One or more of the options below may be used to determine the files shown:
<A NAME="lbAE">&nbsp;</A>
<H2>OPTIONS</H2>
<P>
-c, --cached
<DL COMPACT><DT id="1"><DD>
Show cached files in the output (default)
</DL>
<P>
-d, --deleted
<DL COMPACT><DT id="2"><DD>
Show deleted files in the output
</DL>
<P>
-m, --modified
<DL COMPACT><DT id="3"><DD>
Show modified files in the output
</DL>
<P>
-o, --others
<DL COMPACT><DT id="4"><DD>
Show other (i.e. untracked) files in the output
</DL>
<P>
-i, --ignored
<DL COMPACT><DT id="5"><DD>
Show only ignored files in the output. When showing files in the index, print only those matched by an exclude pattern. When showing &quot;other&quot; files, show only those matched by an exclude pattern. Standard ignore rules are not automatically activated, therefore at least one of the
<B>--exclude*</B>
options is required.
</DL>
<P>
-s, --stage
<DL COMPACT><DT id="6"><DD>
Show staged contents' mode bits, object name and stage number in the output.
</DL>
<P>
--directory
<DL COMPACT><DT id="7"><DD>
If a whole directory is classified as &quot;other&quot;, show just its name (with a trailing slash) and not its whole contents.
</DL>
<P>
--no-empty-directory
<DL COMPACT><DT id="8"><DD>
Do not list empty directories. Has no effect without --directory.
</DL>
<P>
-u, --unmerged
<DL COMPACT><DT id="9"><DD>
Show unmerged files in the output (forces --stage)
</DL>
<P>
-k, --killed
<DL COMPACT><DT id="10"><DD>
Show files on the filesystem that need to be removed due to file/directory conflicts for checkout-index to succeed.
</DL>
<P>
-z
<DL COMPACT><DT id="11"><DD>
\0 line termination on output and do not quote filenames. See OUTPUT below for more information.
</DL>
<P>
-x &lt;pattern&gt;, --exclude=&lt;pattern&gt;
<DL COMPACT><DT id="12"><DD>
Skip untracked files matching pattern. Note that pattern is a shell wildcard pattern. See EXCLUDE PATTERNS below for more information.
</DL>
<P>
-X &lt;file&gt;, --exclude-from=&lt;file&gt;
<DL COMPACT><DT id="13"><DD>
Read exclude patterns from &lt;file&gt;; 1 per line.
</DL>
<P>
--exclude-per-directory=&lt;file&gt;
<DL COMPACT><DT id="14"><DD>
Read additional exclude patterns that apply only to the directory and its subdirectories in &lt;file&gt;.
</DL>
<P>
--exclude-standard
<DL COMPACT><DT id="15"><DD>
Add the standard Git exclusions: .git/info/exclude, .gitignore in each directory, and the user's global exclusion file.
</DL>
<P>
--error-unmatch
<DL COMPACT><DT id="16"><DD>
If any &lt;file&gt; does not appear in the index, treat this as an error (return 1).
</DL>
<P>
--with-tree=&lt;tree-ish&gt;
<DL COMPACT><DT id="17"><DD>
When using --error-unmatch to expand the user supplied &lt;file&gt; (i.e. path pattern) arguments to paths, pretend that paths which were removed in the index since the named &lt;tree-ish&gt; are still present. Using this option with
<B>-s</B>
or
<B>-u</B>
options does not make any sense.
</DL>
<P>
-t
<DL COMPACT><DT id="18"><DD>
This feature is semi-deprecated. For scripting purpose,
<B><A HREF="/cgi-bin/man/man2html?1+git-status">git-status</A></B>(1)
<B>--porcelain</B>
and
<B><A HREF="/cgi-bin/man/man2html?1+git-diff-files">git-diff-files</A></B>(1)
<B>--name-status</B>
are almost always superior alternatives, and users should look at
<B><A HREF="/cgi-bin/man/man2html?1+git-status">git-status</A></B>(1)
<B>--short</B>
or
<B><A HREF="/cgi-bin/man/man2html?1+git-diff">git-diff</A></B>(1)
<B>--name-status</B>
for more user-friendly alternatives.
<P>
This option identifies the file status with the following tags (followed by a space) at the start of each line:
<P>
H
<DL COMPACT><DT id="19"><DD>
cached
</DL>
<P>
S
<DL COMPACT><DT id="20"><DD>
skip-worktree
</DL>
<P>
M
<DL COMPACT><DT id="21"><DD>
unmerged
</DL>
<P>
R
<DL COMPACT><DT id="22"><DD>
removed/deleted
</DL>
<P>
C
<DL COMPACT><DT id="23"><DD>
modified/changed
</DL>
<P>
K
<DL COMPACT><DT id="24"><DD>
to be killed
</DL>
<P>
?
<DL COMPACT><DT id="25"><DD>
other
</DL>
</DL>
<P>
-v
<DL COMPACT><DT id="26"><DD>
Similar to
<B>-t</B>, but use lowercase letters for files that are marked as
<I>assume unchanged</I>
(see
<B><A HREF="/cgi-bin/man/man2html?1+git-update-index">git-update-index</A></B>(1)).
</DL>
<P>
-f
<DL COMPACT><DT id="27"><DD>
Similar to
<B>-t</B>, but use lowercase letters for files that are marked as
<I>fsmonitor valid</I>
(see
<B><A HREF="/cgi-bin/man/man2html?1+git-update-index">git-update-index</A></B>(1)).
</DL>
<P>
--full-name
<DL COMPACT><DT id="28"><DD>
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.
</DL>
<P>
--recurse-submodules
<DL COMPACT><DT id="29"><DD>
Recursively calls ls-files on each submodule in the repository. Currently there is only support for the --cached mode.
</DL>
<P>
--abbrev[=&lt;n&gt;]
<DL COMPACT><DT id="30"><DD>
Instead of showing the full 40-byte hexadecimal object lines, show only a partial prefix. Non default number of digits can be specified with --abbrev=&lt;n&gt;.
</DL>
<P>
--debug
<DL COMPACT><DT id="31"><DD>
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.
</DL>
<P>
--eol
<DL COMPACT><DT id="32"><DD>
Show &lt;eolinfo&gt; and &lt;eolattr&gt; of files. &lt;eolinfo&gt; is the file content identification used by Git when the &quot;text&quot; attribute is &quot;auto&quot; (or not set and core.autocrlf is not false). &lt;eolinfo&gt; is either &quot;-text&quot;, &quot;none&quot;, &quot;lf&quot;, &quot;crlf&quot;, &quot;mixed&quot; or &quot;&quot;.
<P>
&quot;&quot; means the file is not a regular file, it is not in the index or not accessible in the working tree.
<P>
&lt;eolattr&gt; is the attribute that is used when checking out or committing, it is either &quot;&quot;, &quot;-text&quot;, &quot;text&quot;, &quot;text=auto&quot;, &quot;text eol=lf&quot;, &quot;text eol=crlf&quot;. Since Git 2.10 &quot;text=auto eol=lf&quot; and &quot;text=auto eol=crlf&quot; are supported.
<P>
Both the &lt;eolinfo&gt; in the index (&quot;i/&lt;eolinfo&gt;&quot;) and in the working tree (&quot;w/&lt;eolinfo&gt;&quot;) are shown for regular files, followed by the (&quot;attr/&lt;eolattr&gt;&quot;).
</DL>
<P>
--
<DL COMPACT><DT id="33"><DD>
Do not interpret any more arguments as options.
</DL>
<P>
&lt;file&gt;
<DL COMPACT><DT id="34"><DD>
Files to show. If no files are given all files which match the other specified criteria are shown.
</DL>
<A NAME="lbAF">&nbsp;</A>
<H2>OUTPUT</H2>
<P>
<I>git ls-files</I> just outputs the filenames unless <B>--stage</B> is specified in which case it outputs:
<P>
<DL COMPACT><DT id="35"><DD>
<PRE>
[&lt;tag&gt; ]&lt;mode&gt; &lt;object&gt; &lt;stage&gt; &lt;file&gt;
</PRE>
</DL>
<P>
<I>git ls-files --eol</I> will show i/&lt;eolinfo&gt;&lt;SPACES&gt;w/&lt;eolinfo&gt;&lt;SPACES&gt;attr/&lt;eolattr&gt;&lt;SPACE*&gt;&lt;TAB&gt;&lt;file&gt;
<P>
<I>git ls-files --unmerged</I> and <I>git ls-files --stage</I> can be used to examine detailed information on unmerged paths.
<P>
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 <B><A HREF="/cgi-bin/man/man2html?1+git-read-tree">git-read-tree</A></B>(1) for more information on state)
<P>
Without the <B>-z</B> option, pathnames with &quot;unusual&quot; characters are quoted as explained for the configuration variable <B>core.quotePath</B> (see <B><A HREF="/cgi-bin/man/man2html?1+git-config">git-config</A></B>(1)). Using <B>-z</B> the filename is output verbatim and the line is terminated by a NUL byte.
<A NAME="lbAG">&nbsp;</A>
<H2>EXCLUDE PATTERNS</H2>
<P>
<I>git ls-files</I> can use a list of &quot;exclude patterns&quot; when traversing the directory tree and finding files to show when the flags --others or --ignored are specified. <B><A HREF="/cgi-bin/man/man2html?5+gitignore">gitignore</A></B>(5) specifies the format of exclude patterns.
<P>
These exclude patterns come from these places, in order:
<P>
<DL COMPACT><DT id="36"><DD>
1.
The command-line flag --exclude=&lt;pattern&gt; specifies a single pattern. Patterns are ordered in the same order they appear in the command line.
</DL>
<P>
<DL COMPACT><DT id="37"><DD>
2.
The command-line flag --exclude-from=&lt;file&gt; specifies a file containing a list of patterns. Patterns are ordered in the same order they appear in the file.
</DL>
<P>
<DL COMPACT><DT id="38"><DD>
3.
The command-line flag --exclude-per-directory=&lt;name&gt; specifies a name of the file in each directory
<I>git ls-files</I>
examines, normally
<B>.gitignore</B>. Files in deeper directories take precedence. Patterns are ordered in the same order they appear in the files.
</DL>
<P>
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.
<A NAME="lbAH">&nbsp;</A>
<H2>SEE ALSO</H2>
<P>
<B><A HREF="/cgi-bin/man/man2html?1+git-read-tree">git-read-tree</A></B>(1), <B><A HREF="/cgi-bin/man/man2html?5+gitignore">gitignore</A></B>(5)
<A NAME="lbAI">&nbsp;</A>
<H2>GIT</H2>
<P>
Part of the <B><A HREF="/cgi-bin/man/man2html?1+git">git</A></B>(1) suite
<P>
<HR>
<A NAME="index">&nbsp;</A><H2>Index</H2>
<DL>
<DT id="39"><A HREF="#lbAB">NAME</A><DD>
<DT id="40"><A HREF="#lbAC">SYNOPSIS</A><DD>
<DT id="41"><A HREF="#lbAD">DESCRIPTION</A><DD>
<DT id="42"><A HREF="#lbAE">OPTIONS</A><DD>
<DT id="43"><A HREF="#lbAF">OUTPUT</A><DD>
<DT id="44"><A HREF="#lbAG">EXCLUDE PATTERNS</A><DD>
<DT id="45"><A HREF="#lbAH">SEE ALSO</A><DD>
<DT id="46"><A HREF="#lbAI">GIT</A><DD>
</DL>
<HR>
This document was created by
<A HREF="/cgi-bin/man/man2html">man2html</A>,
using the manual pages.<BR>
Time: 00:05:14 GMT, March 31, 2021
</BODY>
</HTML>