名称
git-diff - commits之间,commit与工作树之间的差异等
概要
git diff [<options>] [<commit>] [--] [<path>…]
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>
描述
Show changes between the working tree and the index or a tree, changes between the index and a tree, changes between two trees, changes resulting from a merge, changes between two blob objects, or changes between two files on disk.
-
git diff [<options>] [--] [<path>…]
该表单用于查看工作区相对于索引(下一次提交的暂存区域)所做的更改,即工作区与暂存区的差异。
You can stage these changes by using [git-add1].
-
git diff [<options>] --cached [--merge-base] [<commit>] [--] [<path>…]
此表单用于查看您为下一次提交所做的更改与指定的<commit>之间的差异,即显示暂存区和提交(commit)的差异。
通常,您需要与最新提交进行比较,因此,如果您不提供<commit>,则默认为HEAD。
如果HEAD不存在(例如未出生的分支)并且未给出<commit>,它将显示所有已暂存的更改。
–staged是–cached的同义词。
-
git diff [<options>] --no-index [--] <path> <path>
比较文件系统上给定的两个路径。
当在由Git控制的工作树中运行命令时,可以省略
--no-index
选项,并且至少有一个路径指向工作树之外,或者在由Git控制的工作树外部运行命令时,也可以省略。 -
git diff [<options>] <commit> [--] [<path>…]
此表单用于查看工作区中相对于名为<commit>的差异,即工作与与提交(commit)的差异。
您可以通过使用HEAD将其与最新提交进行比较,或通过使用分支名称将其与其他分支进行比较。
-
git diff [<options>] <commit> <commit> [--] [<path>…]
查看两个任意<commit>之间的更改。
-
git diff [<options>] <commit>..<commit> [--] [<path>…]
这与以前的形式(没有…的格式)同义,即查看两个任意<commit>之间的更改。
如果省略了一侧的<commit>,它将具有与使用HEAD相同的效果。
-
git diff [<options>] <commit>...<commit> [--] [<path>…]
该表格用于查看包含且直到第二个<commit>的分支上的更改,该更改始于两个<commit>的共同祖先。
git diff A...B
is equivalent togit diff $(git merge-base A B) B
.You can omit any one of <commit>, which has the same effect as using HEAD instead.
-
git diff [<options>] <blob> <blob>
此表格用于查看两个Blob对象的原始内容之间的差异。
查看diff时退出
在查看diff时,如果需要退出,按q即可