GIT检查与比较命令之git-diff

名称

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 to git 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即可

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值