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