这些git diff命令有什么区别? [英] What are the differences between these git diff commands?
本文介绍了这些git diff命令有什么区别?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
以下git命令有什么不同?
What are the differences between the following git commands?
-
git diff HEAD
-
git diff HEAD ^
-
git diff - 缓存
或同义词git diff --staged
-
git diff
git diff HEAD
git diff HEAD^
git diff --cached
or the synonymgit diff --staged
git diff
推荐答案
-
git diff HEAD
- 显示自上次提交以来发生的变化。 显示自 -
git diff
- 通过git add
显示已更改但尚未添加到索引中的内容。
git add
但尚未提交的内容添加到索引中的内容。 git diff HEAD
- Shows what has changed since the last commit.git diff HEAD^
- Shows what has changed since the commit before the latest commit.git diff --cached
- Show what has been added to the index viagit add
but not yet committed.git diff
- Show what has changed but hasn't been added to the index yet viagit add
.
看起来像这样:
It looks like this:
Working
Directory <----+--------+------+
| | | |
| | | |
V | | |
"git add" | | |
| diff | |
| | | |
V | | |
Index <----+ diff HEAD |
| | | |
| | | |
V | | |
"git commit" | | |
| diff --cached | |
| diff --staged | |
V | | |
HEAD <----+--------+ |
| |
| diff HEAD^
V |
previous "git commit" |
| |
| |
V |
HEAD^ <--------------------+
这篇关于这些git diff命令有什么区别?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文