Git Diff
名称
git-diff - 显示两个提交,提交和工作树等等之间的变化
语法
git diff [<options>] [<commit>] [--] [<path>…]
## 这个模式默认是比较工作树和提交之间的变化,如果不指定commit,则是和索引区比较
git diff [<options>] --cached [--merge-base] [<commit>] [--] [<path>…]
git diff [<options>] [--merge-base] <commit> [<commit>…] <commit> [--] [<path>…]
git diff [<options>] <commit>…<commit> [--] [<path>…]
git diff [<options>] <blob> <blob>
git diff [<options>] --no-index [--] <path> <path>
显示工作树和索引或树之间的更改、索引和树之间的更改、两棵树之间的更改、合并导致的更改、两个blob对象之间的更改或磁盘上两个文件之间的更改。
使用
default
git diff ## 比较工作树和索引区变化
git diff f311f0 ## 比较工作树和指定提交的内容变化
git diff f311f0 -- diff.md ## 比较工作树和指定提交中文件名称为diff.md内容变化
--no-index
git diff --no-index -- checkout.md rebase.md
## 比较文件系统中两个文件的不同
--cached
git diff --cached HEAD -- checkout.md ## 比较索引区和指定提交中文件名称为checkout.md的内容变化
--merge-base
git diff --merge-base f311f0 f311f1
git diff $(git merge-base f311f0 f311f1) f311f1
## 上面的两个命令是等效的
标签:md,git,merge,--,##,Git,diff
From: https://www.cnblogs.com/xysgo/p/17505450.html