推荐答案
git status
本题详细解读
1. 命令作用
git status 命令用于查看工作目录和暂存区的状态。它会显示哪些文件被修改、哪些文件被暂存、哪些文件未被跟踪等信息。
2. 输出内容解析
- Changes to be committed: 这部分列出了已经暂存(
git add)但尚未提交的修改。 - Changes not staged for commit: 这部分列出了已经修改但尚未暂存的文件。
- Untracked files: 这部分列出了未被 Git 跟踪的文件,通常是新创建的文件。
3. 示例输出
// www.javascriptcn.com code example
$ git status
On branch main
Changes to be committed:
(use "git restore --staged <file>..." to unstage)
modified: README.md
Changes not staged for commit:
(use "git add <file>..." to update what will be committed)
(use "git restore <file>..." to discard changes in working directory)
modified: index.html
Untracked files:
(use "git add <file>..." to include in what will be committed)
newfile.txt4. 其他相关命令
git diff: 查看未暂存的修改。git diff --cached: 查看已暂存的修改。git log: 查看提交历史。