git status 命令

约 505 字 更新于 2026-11-18 5iyo.com

git status 命令


git status 是一个用于查看 Git 仓库当前状态的命令。

git status 命令可以查看在你上次提交之后是否有对文件进行再次修改。


$ git status

On branch master



Initial commit



Changes to be committed:

  (use "git rm --cached <file>..." to unstage)



    new file:   README

    new file:   hello.php

git status 命令会显示以下信息:

  • 当前分支的名称。
  • 当前分支与远程分支的关系(例如,是否是最新的)。
  • 未暂存的修改:显示已修改但尚未使用 git add 添加到暂存区的文件列表。
  • 未跟踪的文件:显示尚未纳入版本控制的新文件列表。

根据 git status 的输出,你可以判断当前工作目录中的文件状态,并采取适当的操作。

通常我们使用 -s 参数来获得简短的输出结果:


$ git status -s

AM README

A  hello.php

git status 命令 示意图

AM 状态的意思是这个文件在我们将它添加到缓存之后又有改动。