gitdiff命令详解diff⾥⾯a表⽰前⾯那个变量,b表⽰第⼆个变量
HEAD    commit版本
Index    staged版本
a、查看尚未暂存的⽂件更新了哪些部分,不加参数直接输⼊
git diff
此命令⽐较的是⼯作⽬录(Working tree)和暂存区域快照(index)之间的差异
也就是修改之后还没有暂存起来的变化内容。
b、查看已经暂存起来的⽂件(staged)和上次提交时的快照之间(HEAD)的差异
git diff --cached
git diff --staged
显⽰的是下⼀次commit时会提交到HEAD的内容(不带-a情况下)
c、显⽰⼯作版本(Working tree)和HEAD的差别
git diff HEADgit使用详解
d、直接将两个分⽀上最新的提交做diff
git diff topic master 或 git aster
e、输出⾃topic和master分别开发以来,master分⽀上的changed。
git aster
Changes that occurred on the master branch since when the topic
branch was started off it
f、查看简单的diff结果,可以加上--stat参数
git diff --stat
g、查看当前⽬录和另外⼀个分⽀的差别
git diff test
显⽰当前⽬录和另⼀个叫'test'分⽀的差别
git diff HEAD -- ./lib
显⽰当前⽬录下的lib⽬录和上次提交之间的差别(更准确的说是在当前分⽀下)
h、⽐较上次提交commit和上上次提交
git diff HEAD^ HEAD
i、⽐较两个历史版本之间的差异
git diff SHA1 SHA2