git diff
git diff
命令用于查看文件之间的差异。
# 查看工作区与暂存区的差异
$ git diff
# 查看某个文件的工作区与暂存区的差异
$ git diff file.txt
# 查看暂存区与当前 commit 的差异
$ git diff --cached
# 查看两个commit的差异
$ git diff <commitBefore> <commitAfter>
# 查看暂存区与仓库区的差异
$ git diff --cached
# 查看工作区与上一次commit之间的差异
# 即如果执行 git commit -a,将提交的文件
$ git diff HEAD
# 查看工作区与某个 commit 的差异
$ git diff <commit>
# 显示两次提交之间的差异
$ git diff [first-branch]...[second-branch]
# 查看工作区与当前分支上一次提交的差异,但是局限于test文件
$ git diff HEAD -- ./test
# 查看当前分支上一次提交与上上一次提交之间的差异
$ git diff HEAD -- ./test
# 生成patch
$ git format-patch master --stdout > mypatch.patch
比较两个分支