Git,如何显示未提交的更改

如何在Git中显示未提交的更改? 我SFTW'ed,这些命令不起作用。

teyan@TEYAN-THINK MINGW64 /d/nano/repos/PSTools/psservice (teyan/psservice) $ git status On branch teyan/psservice Your branch is up-to-date with 'origin/teyan/psservice'. Changes to be committed: (use "git reset HEAD <file>..." to unstage) modified: psservice.c modified: psservice.vcxproj.filters teyan@TEYAN-THINK MINGW64 /d/nano/repos/PSTools/psservice (teyan/psservice) $ git diff teyan@TEYAN-THINK MINGW64 /d/nano/repos/PSTools/psservice (teyan/psservice) $ git diff master fatal: ambiguous argument 'master': unknown revision or path not in the working tree. Use '--' to separate paths from revisions, like this: 'git <command> [<revision>...] -- [<file>...]' 

如何在Git中显示未提交的更改

你正在寻找的命令是git diff

git diff – 显示提交,提交和工作树之间的变化等


以下是一些您可以使用的选项

git diff (无参数)
打印你的工作目录和索引之间的差异。

git diff --cached
打印索引和HEAD(当前提交)之间的差异。

git diff HEAD
打印你的工作目录和HEAD之间的差异。

git diff --name-only
仅显示已更改文件的名称。

git diff --name-status
仅显示已更改文件的名称和状态

git diff --color-words
逐词而不是一行一行。

以下是git diff --color-words的输出示例:

在这里输入图像说明

你已经进行了更改(大概是通过运行git add ),所以为了得到它们的差异,你需要运行:

 git diff --cached 

(一个普通的git diff只会显示未分离的更改。)