mirror of
https://github.com/jaywcjlove/reference.git
synced 2025-06-17 04:31:22 +08:00
doc(git): update docs/git.md (#931)
This commit is contained in:
49
docs/git.md
49
docs/git.md
@ -1287,6 +1287,55 @@ Conventional Commmits
|
||||
| `test:` | 添加测试代码或修正已有的测试 |
|
||||
<!--rehype:className=left-align-->
|
||||
|
||||
|
||||
patch 补丁的使用
|
||||
----
|
||||
|
||||
### 简单创建
|
||||
|
||||
```bash
|
||||
$ git diff commit_id > my.patch
|
||||
```
|
||||
|
||||
### 简单应用
|
||||
|
||||
- **检查**补丁
|
||||
|
||||
```bash
|
||||
# 检查下这个补丁能否被正常应用
|
||||
$ git apply --check path/to/my.patch
|
||||
```
|
||||
|
||||
- **使用**补丁
|
||||
|
||||
```
|
||||
# 检查通过使用该补丁
|
||||
$ git apply < path/to/my.patch
|
||||
```
|
||||
|
||||
- 若有冲突则**解决**
|
||||
|
||||
```
|
||||
# 检查不通过可以自动合入patch不冲突的代码,同时保留冲突部分
|
||||
$ git apply --reject path/to/my.patch
|
||||
```
|
||||
|
||||
<!--rehype:className=style-timeline-->
|
||||
|
||||
### Email patch 方式
|
||||
|
||||
```bash
|
||||
# 创建指定 commit sha1 id 之前的 n 次提交补丁
|
||||
$ git format-patch commit_id -n
|
||||
# 创建 300f59991f22826c8478f0c019387c4ca815b085 这个提交的patch
|
||||
$ git format-patch commit_id -1
|
||||
# 提取当前分支最上面的3次提交,生成补丁
|
||||
$ git format-patch -3
|
||||
# 发送者可使用 git-send-email 发送 git format-patch 的结果给接收者
|
||||
# 接收者保存邮件到文件 email.txt,然后应用补丁创建一个提交,会自动包含作者的信息
|
||||
$ git am < email.txt
|
||||
```
|
||||
|
||||
另见
|
||||
---
|
||||
|
||||
|
Reference in New Issue
Block a user