git am
git
用法
git am [-3] <mbox|patch>...把邮件里的补丁变成提交,保留原作者和原始信息;中途失败时会停在系列中间,得用 --continue、--skip 或 --abort 收尾。
常用选项
| 选项 | 含义 |
|---|---|
| -3 | three-way merge when the patch does not apply cleanly |
| -s | add a Signed-off-by line |
| --continue | go on after you fixed the conflict |
| --skip | drop this patch and continue the series |
| --abort | undo the whole series |
| -k | keep the subject line exactly as it is |
示例
git am 0001-fix-login.patchcommits the patch, keeping its original author
git am -3 *.patchapplies a whole series, merging where needed
git am --abortreturns to before the series started
难的地方在于撤销有好几种:把分支的指向挪走,和补一个反向提交,不是一回事。
怎么看
- 方括号 [ ] 表示这部分可以不写。
- 省略号 … 表示可以写多个。
- 选项区分大小写——有些命令里 -r 和 -R 不是一回事。
常见问题
Q. git am 是做什么的?
把邮件里的补丁变成提交,保留原作者和原始信息;中途失败时会停在系列中间,得用 --continue、--skip 或 --abort 收尾。
Q. 怎么写?
git am [-3] <mbox|patch>... —— 方括号表示可以省略的部分。
Q. 值得记的选项有几个?
这里列了 6 个,完整列表在 man git。这条命令属于git。
相关命令
man 手册: man git-am