目录 搜索
Guides gitattributes giteveryday gitglossary gitignore gitmodules gitrevisions gittutorial gitworkflows Administration git archive git bundle git clean git filter-branch git fsck git gc git instaweb git reflog Basic Snapshotting git add git commit git diff git mv git reset git rm git status Branching and Merging git branch git checkout git log git merge git mergetool git stash git tag Debugging git bisect git blame git grep Email git am git format-patch git request-pull git send-email External Systems git fast-import git svn Getting and Creating Projects git clone git init Git git annotate git archimport git bisect-lk2009 git check-attr git check-mailmap git check-ref-format git checkout-index git cherry git citool git column git credential git credential-cache git credential-store git cvsexportcommit git cvsimport git cvsserver git diff-files git diff-tree git difftool git fast-export git fetch-pack git fmt-merge-msg git get-tar-commit-id git gui git http-backend git http-fetch git http-push git imap-send git index-pack git interpret-trailers git ls-remote git ls-tree git mailinfo git mailsplit git merge-file git merge-index git merge-one-file git merge-tree git mktag git mktree git name-rev git notes git p4 git pack-objects git pack-redundant git pack-refs git parse-remote git patch-id git prune git prune-packed git quiltimport git receive-pack git remote-ext git remote-fd git remote-testgit git repack git replace git rerere git send-pack git sh-i18n git sh-setup git shell git show-branch git show-index git stripspace git unpack-file git unpack-objects git upload-archive git upload-pack git var git verify-commit git verify-tag git whatchanged git worktree Inspection and Comparison git describe git shortlog git show Miscellaneous api credentials api index gitcli gitcore tutorial gitcredentials gitcvs migration gitdiffcore githooks gitk gitnamespaces gitremote helpers gitrepository layout gitsubmodules gittutorial 2 gitweb gitweb.conf pack format User Manual Patching git apply git cherry-pick git rebase git revert Plumbing Commands git cat-file git check-ignore git commit-tree git count-objects git diff-index git for-each-ref git hash-object git ls-files git merge-base git read-tree git rev-list git rev-parse git show-ref git symbolic-ref git update-index git update-ref git verify-pack git write-tree Server Admin git daemon git update-server-info Setup and Config git git config git help Sharing and Updating Projects git fetch git pull git push git remote git submodule
文字

命名

git-status  - 显示工作树的状态

概要

git status [<options>…] [--] [<pathspec>…]

描述

显示索引文件和当前HEAD提交之间存在差异的路径,工作树和索引文件之间存在差异的路径,以及工作树中未由Git跟踪的路径(并且不会被gitignore [5]忽略) )。首先是你would通过跑步提交的内容git commit; 第二和第三是could在运行git add之前运行的内容git commit

选项

-s   --short

以短格式输出输出。

-b   --branch

甚至以短格式显示分支和跟踪信息。

--show-stash

显示当前隐藏的条目数量。

--porcelain=<version>

为脚本提供易于解析格式的输出。这与短输出类似,但在Git版本中保持稳定,并且不管用户配置如何。详情请参阅下文。

版本参数用于指定格式版本。这是可选的,默认为原始版本v1格式。

--long

以长格式输出输出。这是默认设置。

-v   --verbose

除了已更改的文件名称之外,还会显示将要提交的文本更改(即与输出一样git diff --cached)。如果-v指定了两次,那么还会显示尚未上演的工作树中的更改(即与输出一样git diff)。

-u<mode>   --untracked-files=<mode>

显示未跟踪的文件。

The mode parameter is used to specify the handling of untracked files. It is optional: it defaults to all, and if specified, it must be stuck to the option (e.g. -uno, but not -u no).

可能的选项是:

  • no  - 不显示未跟踪的文件。

  • normal  - 显示未跟踪的文件和目录。

  • all- 还显示未跟踪目录中的单个文件。当-u不使用选项时,显示未跟踪的文件和目录(即与指定相同normal),以帮助您避免忘记添加新创建的文件。由于需要额外的工作才能在文件系统中查找未跟踪的文件,因此在大型工作树中,此模式可能需要一些时间。考虑启用未跟踪缓存和分离指标如果支持的话(见git update-index --untracked-cachegit update-index --split-index),否则,你可以使用nogit status返回更快,而不会显示未跟踪的文件。可以使用git-config [1]中记录的status.showUntrackedFiles配置变量来更改默认值。--ignore-submodules = <when>查找更改时忽略对子模块的更改。<when>可以是“none”,“untracked”,“dirty”或“all”,这是默认设置。如果子模块包含未跟踪或已修改的文件,或者HEAD与超级项目中记录的提交不同,并且可用于覆盖ignore选项在git-config [1]或gitmodules [5]中。当使用“未跟踪”时,如果子模块仅包含未跟踪内容(但仍然针对修改内容进行扫描),则子模块不会被视为脏。使用“dirty”忽略对子模块工作树的所有更改,只显示存储在超级项目中的提交更改(这是1.7.0之前的行为)。使用“all”隐藏对子模块的所有更改(并在status.submoduleSummary设置了配置选项时禁止输出子模块摘要)。 - 也显示忽略的文件。-z使用NUL而不是LF终止条目。--porcelain=v1如果没有给出其他格式,这意味着输出格式。--column = <选项> --no-column在列中显示未跟踪的文件。有关选项语法,请参阅配置变量column.status。--column--no-column没有选项相当于alwaysnever分别。<pathspec> ...请参阅pathspecgitglossary [7]中的条目。输出此命令的输出旨在用作提交模板注释。默认的长格式设计为人类可读,详细和描述性的。它的内容和格式随时可能发生变化。输出中提到的路径与其他许多Git命令不同,它是相对于当前目录而言的,如果您在子目录中工作(这是为了帮助剪切和粘贴)。请参阅下面的status.relativePaths配置选项。小格式在短格式中,每个路径的状态显示为XY PATH1  - > PATH2其中PATH1是路径HEAD,而“ -> PATH2”部分仅在显示时显示PATH1对应于索引/工作树中的不同路径(即文件被重命名)。这XY是一个双字母状态码。字段(包括->)由一个空格相互分隔。如果文件名包含空格或其他非打印字符,则该字段将以C字符串文字的方式引用:由ASCII双引号(34)字符包围,并且包含内部特殊字符反斜线转义。对于具有合并冲突的路径,X以及Y显示合并每一侧的修改状态。对于没有合并冲突的路径,X显示索引Y的状态,并显示工作树的状态。对于未跟踪的路径,XY??。其他状态代码可以解释如下:

  • ''=未修改

  • M =修改

  • A =已添加

  • D =已删除

  • R =重命名

  • C =复制

  • U =已更新但尚未装入

被忽略的文件未列出,除非--ignored选项生效,在这种情况下XY!!

X          Y     Meaning-------------------------------------------------          [MD]   not updated
M        [ MD]   updated in index
A        [ MD]   added to index
D         [ M]   deleted from index
R        [ MD]   renamed in index
C        [ MD]   copied in index[MARC]           index and work tree matches[ MARC]     M    work tree changed since index[ MARC]     D    deleted in work tree-------------------------------------------------D           D    unmerged, both deleted
A           U    unmerged, added by us
U           D    unmerged, deleted by them
U           A    unmerged, added by them
D           U    unmerged, deleted by us
A           A    unmerged, both added
U           U    unmerged, both modified-------------------------------------------------?           ?    untracked!           !    ignored-------------------------------------------------

子模块具有更多的状态,相反,报告M子模块具有与索引m中记录的HEAD不同的子模块具有修改的内容?子模块具有未跟踪文件,因为子模块中的修改内容或未跟踪文件无法通过git add超级项目添加以准备提交。

m?递归应用。例如,如果子模块中的嵌套子模块包含未跟踪文件,则也会报告此情况?

如果使用-b,则短格式状态前面有一行

## branchname tracking info

Porcelain Format Version 1

版本1的瓷质格式与短格式类似,但保证不会以Git版本之间不兼容的方式或基于用户配置进行更改。这使它成为脚本解析的理想选择。上面短格式的描述也描述了瓷器格式,但有一些例外:

  • 用户的color.status配置不受尊重; 颜色将始终关闭。

  • 用户的status.relativePaths配置不受尊重; 显示的路径将始终与存储库根目录相关。

还有一种推荐用于机器解析的备用-z格式。在这种格式下,状态字段是相同的,但其他一些事情会改变。首先,->从重命名条目中忽略该字段,并且字段顺序颠倒(例如from -> to变成to from)。其次,NUL(ASCII 0)跟在每个文件名后面,将空格替换为字段分隔符和终止换行符(但空格仍将状态字段与第一个文件名隔开)。第三,包含特殊字符的文件名不是专门格式化的; 不执行引用或反斜杠转义。

任何子模块更改都将报告为已修改M而不是m或单个报告?

Porcelain Format Version 2

版本2格式添加了有关工作树状态和更改项目的更详细信息。第2版还定义了一套易于解析可选标题的可扩展集合。

标题行以“#”开头,并在响应特定命令行参数时添加。解析器应该忽略它们不认识的标题。

Branch Headers

如果--branch给出,则会打印一系列标题行,其中包含有关当前分支的信息。

Line                                     Notes------------------------------------------------------------# branch.oid <commit> | (initial)        Current commit.# branch.head <branch> | (detached)      Current branch.# branch.upstream <upstream_branch>      If upstream is set.# branch.ab +<ahead> -<behind>           If upstream is set and
             the commit is present.------------------------------------------------------------

Changed Tracked Entries

在标题之后,会打印一系列行以跟踪条目。取决于改变的类型,可以使用三种不同的线格式之一来描述条目。被跟踪的条目以未定义的顺序打印; 解析器应该允许以任何顺序混合3种线型。

普通更改的条目具有以下格式:

1 <XY> <sub> <mH> <mI> <mW> <hH> <hI> <path>

Renamed or copied entries have the following format:

2 <XY> <sub> <mH> <mI> <mW> <hH> <hI> <X><score> <path><sep><origPath>
  Field       Meaning  --------------------------------------------------------  <XY>        A 2 character field containing the staged and
unstaged XY values described in the short format,with unchanged indicated by a "." rather than
a space.  <sub>       A 4 character field describing the submodule state."N..." when the entry is not a submodule."S<c><m><u>" when the entry is a submodule.<c> is "C" if the commit changed; otherwise ".".<m> is "M" if it has tracked changes; otherwise ".".<u> is "U" if there are untracked changes; otherwise ".".  <mH>        The octal file mode in HEAD.  <mI>        The octal file mode in the index.  <mW>        The octal file mode in the worktree.  <hH>        The object name in HEAD.  <hI>        The object name in the index.  <X><score>  The rename or copy score (denoting the percentageof similarity between the source and target of the
move or copy). For example "R100" or "C75".  <path>      The pathname.  In a renamed/copied entry, thisis the path in the index and in the working tree.  <sep>       When the `-z` option is used, the 2 pathnames are separatedwith a NUL (ASCII 0x00) byte; otherwise, a tab (ASCII 0x09)byte separates them.  <origPath>  The pathname in the commit at HEAD.  This is only
present in a renamed/copied entry, and tells
where the renamed/copied contents came from.  --------------------------------------------------------

未合并的条目具有以下格式; 第一个字符是“u”以区别于普通的已更改的条目。

u <xy> <sub> <m1> <m2> <m3> <mW> <h1> <h2> <h3> <path>
  Field       Meaning  --------------------------------------------------------  <XY>        A 2 character field describing the conflict typeas described in the short format.  <sub>       A 4 character field describing the submodule stateas described above.  <m1>        The octal file mode in stage 1.  <m2>        The octal file mode in stage 2.  <m3>        The octal file mode in stage 3.  <mW>        The octal file mode in the worktree.  <h1>        The object name in stage 1.  <h2>        The object name in stage 2.  <h3>        The object name in stage 3.  <path>      The pathname.  --------------------------------------------------------

Other Items

在跟踪的条目(如果请求)之后,会打印一系列行,以便在工作树中找到未跟踪的项目,然后忽略它们。

未跟踪的项目具有以下格式:

? <path>

忽略的项目具有以下格式:

! <path>

Pathname Format Notes and -z

-z给出该选项时,路径名将按原样打印并且不带任何引用,并且行以NUL(ASCII 0x00)字节结尾。

如果没有这个-z选项,带有“不寻常”字符的路径名将按照配置变量的说明引用core.quotePath(请参阅git-config [1])。

Configuration

该命令荣誉color.status(或status.color- 他们意味着相同的事情,后者保持向后兼容性)和color.status.<slot>配置变量来着色其输出。

如果config变量status.relativePaths设置为false,则显示的所有路径都是相对于存储库根目录而不是当前目录。

如果status.submoduleSummary设置为非零数字或true(与-1或无限制数字相同),则将为长格式启用子模块摘要,并显示修改子模块的提交摘要(请参阅--summary-limit选项git-submodule [1])。请注意,状态命令的摘要输出将在所有子模块diff.ignoreSubmodules被设置为all或仅限其中的子模块时被抑制submodule.<name>.ignore=all。要查看忽略子模块的摘要,可以使用--ignore-submodules = dirty命令行选项或git submodule summary命令,该命令显示类似的输出,但不遵守这些设置。

上一篇: 下一篇: