有什么区别git diff HEAD
and git diff --staged
?我尝试了两者,但都给出了相同的输出。
假设这个输出为git status
:
$ git status
# On branch master
# Changes to be committed:
# (use "git reset HEAD <file>..." to unstage)
#
# new file: y
#
# Changes not staged for commit:
# (use "git add <file>..." to update what will be committed)
# (use "git checkout -- <file>..." to discard changes in working directory)
#
# modified: x
#
如您所见,有一个文件已修改但未暂存以供提交,并且添加了一个已准备好提交的新文件。
git diff --staged
只会显示“暂存”区域中文件的更改。
git diff HEAD
将显示跟踪文件的所有更改。如果您已暂存所有更改以供提交,则两个命令将输出相同的内容。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)