转自http://www.cnblogs.com/gbyukg/archive/2011/12/13/2286884.html
git diff 显示工作目录与索引区文件之间的差异
git diff --cached显示索引区与git仓库之间的差异
git diff HEAD 显示工作目录与git仓库之间的差异
git diff HEAD^ 比较上次提交
git diff HEAD~2 比较上2次提交
--diff-filter=[ACDMRTUXB*]
显示指定状态的文件:Added (A), Copied (C), Deleted (D), Modified (M), Renamed (R), changed (T), are Unmerged (U), are Unknown (X)
git difftool 使用图形工具显示文件之间的差异
git diff --stat 列出文件
git diff -- filename 只对比给定的文件
历史提交对比:
$ git diff commit 将所指定的某次提交与当前工作目录进行对比。
$ git diff commit1 commit2 将2次提交的内容进行对比
等价于
$ git diff commit1..commit2 如果省略任意一个commit,默认将使用HEAD代替
commit可以是简写的commit哈希值,也可能是HEAD。其中HEAD代表最后一次提交,HEAD^代表最后一次提交的父提交,HEAD~1等价于HEAD^,HEAD~2为倒数第二次提交,以此类推。