interplane.Get Omega
Read in your language

git

[Ported from github.com/git/git] Sync with Git 2.56.1

Brought by drakestapleton

branch master Branches Tags History

git / Documentation / git-status.adoc

537 lines · 20045 bytes Raw Blame History
1git-status(1)
2=============
3
4NAME
5----
6git-status - Show the working tree status
7
8
9SYNOPSIS
10--------
11
12[synopsis]
13git status [<options>] [--] [<pathspec>...]
14
15DESCRIPTION
16-----------
17Displays paths that have differences between the index file and the
18current HEAD commit, paths that have differences between the working
19tree and the index file, and paths in the working tree that are not
20tracked by Git (and are not ignored by linkgit:gitignore[5]). The first
21are what you _would_ commit by running `git commit`; the second and
22third are what you _could_ commit by running `git add` before running
23`git commit`.
24
25OPTIONS
26-------
27
28`-s`::
29`--short`::
30 Give the output in the short-format.
31
32`-b`::
33`--branch`::
34 Show the branch and tracking info even in short-format.
35
36`--show-stash`::
37 Show the number of entries currently stashed away.
38
39`--porcelain[=<version>]`::
40 Give the output in an easy-to-parse format for scripts.
41 This is similar to the short output, but will remain stable
42 across Git versions and regardless of user configuration. See
43 below for details.
44+
45The _<version>_ parameter is used to specify the format version.
46This is optional and defaults to the original version `v1` format.
47
48`--long`::
49 Give the output in the long-format. This is the default.
50
51`-v`::
52`--verbose`::
53 In addition to the names of files that have been changed, also
54 show the textual changes that are staged to be committed
55 (i.e., like the output of `git diff --cached`). If `-v` is specified
56 twice, then also show the changes in the working tree that
57 have not yet been staged (i.e., like the output of `git diff`).
58
59`-u[<mode>]`::
60`--untracked-files[=<mode>]`::
61 Show untracked files.
62+
63--
64The mode parameter is used to specify the handling of untracked files.
65It is optional: it defaults to `all`, and if specified, it must be
66stuck to the option (e.g. `-uno`, but not `-u no`).
67
68The possible options are:
69
70`no`:: Show no untracked files.
71`normal`:: Show untracked files and directories.
72`all`:: Also show individual files in untracked directories.
73
74When `-u` option is not used, untracked files and directories are
75shown (i.e. the same as specifying `normal`), to help you avoid
76forgetting to add newly created files. Because it takes extra work
77to find untracked files in the filesystem, this mode may take some
78time in a large working tree.
79Consider enabling untracked cache and split index if supported (see
80`git update-index --untracked-cache` and `git update-index
81--split-index`), Otherwise you can use `no` to have `git status`
82return more quickly without showing untracked files.
83All usual spellings for Boolean value `true` are taken as `normal`
84and `false` as `no`.
85
86The default can be changed using the `status.showUntrackedFiles`
87configuration variable documented in linkgit:git-config[1].
88--
89
90`--ignore-submodules[=<when>]`::
91 Ignore changes to submodules when looking for changes. _<when>_ can be
92 either `none`, `untracked`, `dirty` or `all`, which is the default.
93`none`;; will consider the submodule modified when it either contains
94 untracked or modified files or its HEAD differs from the commit recorded
95 in the superproject and can be used to override any settings of the
96 `ignore` option in linkgit:git-config[1] or linkgit:gitmodules[5].
97`untracked`;; submodules are not considered dirty when they only
98 contain untracked content (but they are still scanned for modified
99 content).
100`dirty`;; ignore all changes to the work tree of submodules,
101 only changes to the commits stored in the superproject are shown (this was
102 the behavior before 1.7.0).
103`all`;; hide all changes to submodules
104 (and suppresses the output of submodule summaries when the config option
105 `status.submoduleSummary` is set).
106
107`--ignored[=<mode>]`::
108 Show ignored files as well.
109+
110--
111The mode parameter is used to specify the handling of ignored files.
112It is optional: it defaults to `traditional`.
113
114The possible options are:
115
116`traditional`:: Show ignored files and directories, unless
117`--untracked-files=all` is specified, in which case
118 individual files in ignored directories are
119 displayed.
120`no`:: Show no ignored files.
121`matching`:: Show ignored files and directories matching an
122ignore pattern.
123+
124Paths that explicitly match an
125ignored pattern are shown. If a directory matches an ignore pattern,
126then it is shown, but not paths contained in the ignored directory. If
127a directory does not match an ignore pattern, but all contents are
128ignored, then the directory is not shown, but all contents are shown.
129--
130
131`-z`::
132 Terminate entries with _NUL_, instead of _LF_. This implies
133 the `--porcelain=v1` output format if no other format is given.
134
135`--column[=<options>]`::
136`--no-column`::
137 Display untracked files in columns. See configuration variable
138 `column.status` for option syntax. `--column` and `--no-column`
139 without options are equivalent to `always` and `never`
140 respectively.
141
142`--ahead-behind`::
143`--no-ahead-behind`::
144 Display or do not display detailed ahead/behind counts for the
145 branch relative to its upstream branch. Defaults to `true`.
146
147`--renames`::
148`--no-renames`::
149 Turn on/off rename detection regardless of user configuration.
150 See also linkgit:git-diff[1] `--no-renames`.
151
152`--find-renames[=<n>]`::
153 Turn on rename detection, optionally setting the similarity
154 threshold.
155 See also linkgit:git-diff[1] `--find-renames`.
156
157`<pathspec>...`::
158 See the 'pathspec' entry in linkgit:gitglossary[7].
159
160OUTPUT
161------
162The output from this command is designed to be used as a commit
163template comment.
164The default, long format, is designed to be human readable,
165verbose and descriptive. Its contents and format are subject to change
166at any time.
167
168The paths mentioned in the output, unlike many other Git commands, are
169made relative to the current directory if you are working in a
170subdirectory (this is on purpose, to help cutting and pasting). See
171the status.relativePaths config option below.
172
173Short Format
174~~~~~~~~~~~~
175
176In the short-format, the status of each path is shown as one of these
177forms
178
179 <xy> <path>
180 <xy> <orig-path> -> <path>
181
182where _<orig-path>_ is where the renamed/copied contents came
183from. _<orig-path>_ is only shown when the entry is renamed or
184copied. The _<xy>_ is a two-letter status code `XY`.
185
186The fields (including the `->`) are separated from each other by a
187single space. If a filename contains whitespace or other nonprintable
188characters, that field will be quoted in the manner of a C string
189literal: surrounded by ASCII double quote (34) characters, and with
190interior special characters backslash-escaped.
191
192There are three different types of states that are shown using this format, and
193each one uses the _<xy>_ syntax differently:
194
195* When a merge is occurring and the merge was successful, or outside of a merge
196 situation, `X` shows the status of the index and `Y` shows the status of the
197 working tree.
198* When a merge conflict has occurred and has not yet been resolved, `X` and `Y`
199 show the state introduced by each head of the merge, relative to the common
200 ancestor. These paths are said to be _unmerged_.
201* When a path is untracked, `X` and `Y` are always the same, since they are
202 unknown to the index. `??` is used for untracked paths. Ignored files are
203 not listed unless `--ignored` is used; if it is, ignored files are indicated
204 by `!!`.
205
206Note that the term _merge_ here also includes rebases using the default
207`--merge` strategy, cherry-picks, and anything else using the merge machinery.
208
209In the following table, these three classes are shown in separate sections, and
210these characters are used for `X` and `Y` fields for the first two sections that
211show tracked paths:
212
213' ':: unmodified
214`M`:: modified
215`T`:: file type changed (regular file, symbolic link or submodule)
216`A`:: added
217`D`:: deleted
218`R`:: renamed
219`C`:: copied (if config option status.renames is set to "copies")
220`U`:: updated but unmerged
221
222[cols="^1m,^1m,<2",options="header"]
223|===
224|X | Y |Meaning
225| |[AMD] |not updated
226|M |[ MTD] |updated in index
227|T |[ MTD] |type changed in index
228|A |[ MTD] |added to index
229|D | |deleted from index
230|R |[ MTD] |renamed in index
231|C |[ MTD] |copied in index
232|[MTARC] | |index and work tree matches
233|[ MTARC] |M |work tree changed since index
234|[ MTARC] |T |type changed in work tree since index
235|[ MTARC] |D |deleted in work tree
236| |R |renamed in work tree
237| |C |copied in work tree
238|D |D |unmerged, both deleted
239|A |U |unmerged, added by us
240|U |D |unmerged, deleted by them
241|U |A |unmerged, added by them
242|D |U |unmerged, deleted by us
243|A |A |unmerged, both added
244|U |U |unmerged, both modified
245|? |? |untracked
246|! |! |ignored
247|===
248
249Submodules have more state and instead report
250
251`M`:: the submodule has a different HEAD than recorded in the index
252`m`:: the submodule has modified content
253`?`:: the submodule has untracked files
254
255This is since modified content or untracked files in a submodule cannot be added
256via `git add` in the superproject to prepare a commit.
257
258`m` and `?` are applied recursively. For example if a nested submodule
259in a submodule contains an untracked file, this is reported as `?` as well.
260
261If `-b` is used the short-format status is preceded by a line
262
263[synopsis]
264{empty}## <branchname> <tracking-info>
265
266
267Porcelain Format Version 1
268~~~~~~~~~~~~~~~~~~~~~~~~~~
269
270Version 1 porcelain format is similar to the short format, but is guaranteed
271not to change in a backwards-incompatible way between Git versions or
272based on user configuration. This makes it ideal for parsing by scripts.
273The description of the short format above also describes the porcelain
274format, with a few exceptions:
275
2761. The user's `color.status` configuration is not respected; color will
277 always be off.
278
2792. The user's `status.relativePaths` configuration is not respected; paths
280 shown will always be relative to the repository root.
281
282There is also an alternate `-z` format recommended for machine parsing. In
283that format, the status field is the same, but some other things
284change. First, the `->` is omitted from rename entries and the field
285order is reversed (e.g `from -> to` becomes `to from`). Second, a _NUL_
286(ASCII 0) follows each filename, replacing space as a field separator
287and the terminating newline (but a space still separates the status
288field from the first filename). Third, filenames containing special
289characters are not specially formatted; no quoting or
290backslash-escaping is performed.
291
292Any submodule changes are reported as modified `M` instead of `m` or single `?`.
293
294Porcelain Format Version 2
295~~~~~~~~~~~~~~~~~~~~~~~~~~
296
297Version 2 format adds more detailed information about the state of
298the worktree and changed items. Version 2 also defines an extensible
299set of easy to parse optional headers.
300
301Header lines start with `#` and are added in response to specific
302command line arguments. Parsers should ignore headers they
303don't recognize.
304
305Branch Headers
306^^^^^^^^^^^^^^
307
308If `--branch` is given, a series of header lines are printed with
309information about the current branch.
310
311[cols="<1,<1",options="header"]
312|===
313|Line |Notes
314|`# branch.oid <commit> \| (initial)` |Current commit.
315|`# branch.head <branch> \| (detached)` |Current branch.
316|`# branch.upstream <upstream-branch>` |If upstream is set.
317|`# branch.ab +<ahead> -<behind>` |If upstream is set and
318 the commit is present.
319|===
320
321Stash Information
322^^^^^^^^^^^^^^^^^
323
324If `--show-stash` is given, one line is printed showing the number of stash
325entries if non-zero:
326
327 # stash <N>
328
329Changed Tracked Entries
330^^^^^^^^^^^^^^^^^^^^^^^
331
332Following the headers, a series of lines are printed for tracked
333entries. One of three different line formats may be used to describe
334an entry depending on the type of change. Tracked entries are printed
335in an undefined order; parsers should allow for a mixture of the 3
336line types in any order.
337
338Ordinary changed entries have the following format:
339
340[synopsis]
3411 <XY> <sub> <mH> <mI> <mW> <hH> <hI> <path>
342
343Renamed or copied entries have the following format:
344
345[synopsis]
3462 <XY> <sub> <mH> <mI> <mW> <hH> <hI> <X><score> <path><sep><origPath>
347
348[cols="<1,<1a",options="header"]
349|===
350|Field | Meaning
351
352|_<XY>_
353|A 2 character field containing the staged and
354unstaged XY values described in the short format,
355with unchanged indicated by a "." rather than
356a space.
357|_<sub>_
358|A 4 character field describing the submodule state.
359"N..." when the entry is not a submodule.
360`S<c><m><u>` when the entry is a submodule.
361
362* _<c>_ is "C" if the commit changed; otherwise ".".
363* _<m>_ is "M" if it has tracked changes; otherwise ".".
364* _<u>_ is "U" if there are untracked changes; otherwise ".".
365|_<mH>_ |The octal file mode in HEAD.
366|_<mI>_ |The octal file mode in the index.
367|_<mW>_ |The octal file mode in the worktree.
368|_<hH>_ |The object name in HEAD.
369|_<hI>_ |The object name in the index.
370|_<X><score>_ |The rename or copy score (denoting the percentage
371of similarity between the source and target of the
372move or copy). For example "R100" or "C75".
373|_<path>_
374|The pathname. In a renamed/copied entry, this is the target path.
375|_<sep>_
376|When the `-z` option is used, the 2 pathnames are separated
377with a _NUL_ (ASCII 0x00) byte; otherwise, a _TAB_ (ASCII 0x09)
378byte separates them.
379|_<origPath>_
380|The pathname in the commit at HEAD or in the index.
381This is only present in a renamed/copied entry, and
382tells where the renamed/copied contents came from.
383|===
384
385Unmerged entries have the following format; the first character is
386a "u" to distinguish from ordinary changed entries.
387
388[synopsis]
389u <XY> <sub> <m1> <m2> <m3> <mW> <h1> <h2> <h3> <path>
390
391[cols="<1,<1a",options="header"]
392|===
393|Field |Meaning
394|_<XY>_ |A 2 character field describing the conflict type
395 as described in the short format.
396|_<sub>_ |A 4 character field describing the submodule state
397 as described above.
398|_<m1>_ |The octal file mode in stage 1.
399|_<m2>_ |The octal file mode in stage 2.
400|_<m3>_ |The octal file mode in stage 3.
401|_<mW>_ |The octal file mode in the worktree.
402|_<h1>_ |The object name in stage 1.
403|_<h2>_ |The object name in stage 2.
404|_<h3>_ |The object name in stage 3.
405|_<path>_ |The pathname.
406|===
407
408Other Items
409^^^^^^^^^^^
410
411Following the tracked entries (and if requested), a series of
412lines will be printed for untracked and then ignored items
413found in the worktree.
414
415Untracked items have the following format:
416
417 ? <path>
418
419Ignored items have the following format:
420
421 ! <path>
422
423Pathname Format Notes and -z
424^^^^^^^^^^^^^^^^^^^^^^^^^^^^
425
426When the `-z` option is given, pathnames are printed as is and
427without any quoting and lines are terminated with a _NUL_ (ASCII 0x00)
428byte.
429
430Without the `-z` option, pathnames with "unusual" characters are
431quoted as explained for the configuration variable `core.quotePath`
432(see linkgit:git-config[1]).
433
434
435CONFIGURATION
436-------------
437
438The command honors `color.status` (or `status.color` -- they
439mean the same thing and the latter is kept for backward
440compatibility) and `color.status.<slot>` configuration variables
441to colorize its output.
442
443If the config variable `status.relativePaths` is set to false, then all
444paths shown are relative to the repository root, not to the current
445directory.
446
447If `status.submoduleSummary` is set to a non zero number or true (identical
448to -1 or an unlimited number), the submodule summary will be enabled for
449the long format and a summary of commits for modified submodules will be
450shown (see `--summary-limit` option of linkgit:git-submodule[1]). Please note
451that the summary output from the status command will be suppressed for all
452submodules when `diff.ignoreSubmodules` is set to `all` or only for those
453submodules where `submodule.<name>.ignore=all`. To also view the summary for
454ignored submodules you can either use the `--ignore-submodules=dirty` command
455line option or the 'git submodule summary' command, which shows a similar
456output but does not honor these settings.
457
458BACKGROUND REFRESH
459------------------
460
461By default, `git status` will automatically refresh the index, updating
462the cached stat information from the working tree and writing out the
463result. Writing out the updated index is an optimization that isn't
464strictly necessary (`status` computes the values for itself, but writing
465them out is just to save subsequent programs from repeating our
466computation). When `status` is run in the background, the lock held
467during the write may conflict with other simultaneous processes, causing
468them to fail. Scripts running `status` in the background should consider
469using `git --no-optional-locks status` (see linkgit:git[1] for details).
470
471UNTRACKED FILES AND PERFORMANCE
472-------------------------------
473
474`git status` can be very slow in large worktrees if/when it
475needs to search for untracked files and directories. There are
476many configuration options available to speed this up by either
477avoiding the work or making use of cached results from previous
478Git commands. There is no single optimum set of settings right
479for everyone. We'll list a summary of the relevant options to help
480you, but before going into the list, you may want to run `git status`
481again, because your configuration may already be caching `git status`
482results, so it could be faster on subsequent runs.
483
484* The `--untracked-files=no` flag or the
485 `status.showUntrackedFiles=no` config (see above for both):
486 indicate that `git status` should not report untracked
487 files. This is the fastest option. `git status` will not list
488 the untracked files, so you need to be careful to remember if
489 you create any new files and manually `git add` them.
490
491* `advice.statusUoption=false` (see linkgit:git-config[1]):
492 setting this variable to `false` disables the warning message
493 given when enumerating untracked files takes more than 2
494 seconds. In a large project, it may take longer and the user
495 may have already accepted the trade off (e.g. using `-uno` may
496 not be an acceptable option for the user), in which case, there
497 is no point issuing the warning message, and in such a case,
498 disabling the warning may be the best.
499
500* `core.untrackedCache=true` (see linkgit:git-update-index[1]):
501 enable the untracked cache feature and only search directories
502 that have been modified since the previous `git status` command.
503 Git remembers the set of untracked files within each directory
504 and assumes that if a directory has not been modified, then
505 the set of untracked files within has not changed. This is much
506 faster than enumerating the contents of every directory, but still
507 not without cost, because Git still has to search for the set of
508 modified directories. The untracked cache is stored in the
509 `.git/index` file. The reduced cost of searching for untracked
510 files is offset slightly by the increased size of the index and
511 the cost of keeping it up-to-date. That reduced search time is
512 usually worth the additional size.
513
514* `core.untrackedCache=true` and `core.fsmonitor=true` or
515 `core.fsmonitor=<hook-command-pathname>` (see
516 linkgit:git-update-index[1]): enable both the untracked cache
517 and FSMonitor features and only search directories that have
518 been modified since the previous `git status` command. This
519 is faster than using just the untracked cache alone because
520 Git can also avoid searching for modified directories. Git
521 only has to enumerate the exact set of directories that have
522 changed recently. While the FSMonitor feature can be enabled
523 without the untracked cache, the benefits are greatly reduced
524 in that case.
525
526Note that after you turn on the untracked cache and/or FSMonitor
527features it may take a few `git status` commands for the various
528caches to warm up before you see improved command times. This is
529normal.
530
531SEE ALSO
532--------
533linkgit:gitignore[5]
534
535GIT
536---
537Part of the linkgit:git[1] suite