git 显示文件状态_Git状态–显示工作树状态

本文介绍了如何使用 Git 的 `status` 命令来查看工作目录和暂存区的状态,包括列出跟踪和未跟踪的文件、以短格式显示状态、显示分支状态以及详细状态。通过这些选项,你可以轻松了解 Git 项目的当前状态。
摘要由CSDN通过智能技术生成
git 显示文件状态

git 显示文件状态

The git status command is used to display the state of the current working directory and staging area. git status command will list staged changes, current changes. It will not list any history related information.

git status命令用于显示当前工作目录和暂存区的状态。 git status命令将列出暂存的更改,当前更改。 它不会列出任何历史记录相关信息。

列出跟踪和未跟踪的文件 (List Tracked and Untracked Files)

We will start with a simple git status usage. We do not provide any option. This will list tracked and untracked files in a git repository.

我们将从简单的git status用法开始。 我们不提供任何选择。 这将在git存储库中列出已跟踪和未跟踪的文件。

$ git status
List Tracked and Untracked Files
List Tracked and Untracked Files
列出跟踪和未跟踪的文件

We can see that files named extension.c, pass.c, and pass2.c are not tracked by the git repository. All other files are tracked and their names are not listed.

我们可以看到git存储库未跟踪名为extension.cpass.cpass2.c的文件。 跟踪所有其他文件,并且未列出其名称。

以短格式显示 (Show In Short Format)

If we want to just list the tracked and untracked files and folders in a short form we can use -s. As we can see below only the file and folder and status will be listed. ?? means untracked.

如果我们只想以简短形式列出已跟踪和未跟踪的文件和文件夹,则可以使用-s 。 正如我们在下面看到的,仅列出文件,文件夹和状态。 ?? 表示未跟踪。

$ git status -s
Show In Short Format
Show In Short Format
以短格式显示

From the output, we can see that only untracked file names are listed.

从输出中,我们可以看到仅列出了未跟踪的文件名。

显示分支状态 (Show Branch Status)

If we want to print also the branch status we can provide -b option like below.

如果我们还要打印分支状态,我们可以提供-b选项,如下所示。

$ git status -b
Show Branch Status
Show Branch Status
显示分支状态

详细状态(Verbose Status)

We can also list current tracked and untracked files and folders in a verbose mode. We will use -v option.

我们还可以详细模式列出当前已跟踪和未跟踪的文件和文件夹。 我们将使用-v选项。

$ git status -v
LEARN MORE  What Is Computer Programming?
了解更多什么是计算机编程?

翻译自: https://www.poftut.com/git-status-show-the-working-tree-status/

git 显示文件状态

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值