如何详细显示Git和一些Git差异中未提交的更改 [英] How to show uncommitted changes in Git and some Git diffs in detail
问题描述
如何显示Git中未提交的更改?
How do I show uncommitted changes in Git?
我 STFW'ed ,这些命令不起作用:
I STFW'ed, and these commands are not working:
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中未提交的更改
How to show uncommitted changes in Git
您要查找的命令是 git diff
.
The command you are looking for is git diff
.
git diff
-显示提交,提交和工作树等之间的更改
git diff
- Show changes between commits, commit and working tree, etc
这里有一些您可以使用的选项
Here are some of the options it expose which you can use
git diff
(无参数)
打印出您的工作目录和索引之间的差异.
git diff
(no parameters)
Print out differences between your working directory and the index.
git diff --cached
:
打印出索引和HEAD(当前提交)之间的差异.
git diff --cached
:
Print out differences between the index and HEAD (current commit).
git diff HEAD
:
打印出您的工作目录和HEAD之间的差异.
git diff HEAD
:
Print out differences between your working directory and the HEAD.
git diff --name-only
仅显示已更改文件的名称.
git diff --name-only
Show only names of changed files.
git diff --name-status
仅显示已更改文件的名称和状态.
git diff --name-status
Show only names and status of changed files.
git diff --color-words
逐字差异而不是逐行.
git diff --color-words
Word by word diff instead of line by line.
以下是git diff --color-words
的输出示例:
这篇关于如何详细显示Git和一些Git差异中未提交的更改的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!