diff
最后更新于:2022-04-02 02:53:00
[TOC]
## 场景
### 比较工作区与暂存区
```
git diff
```
### 比较暂存区与最新本地版本库
```
git diff --cached [...]
```
### 比较工作区与最新本地版本库
```
git diff HEAD [...]
```
### 比较工作区与指定commit-id的差异
```
git diff commit-id [...]
```
### 比较两个commit-id之间的差异
```
git diff [] []
```
### 使用git diff打补丁
```
//生成文件
git diff > patch
git diff --cached > patch
git diff --HEAD > patch
git diff Testfile > patch // //将单个文件做成一个单独的补丁
// 应用补丁
git apply --check patch // 如果没有任何输出,那么表示可以顺利接受这个补丁
git apply --reject patch // 将能打的补丁先打上,有冲突的会生成.rej文件
';