- 选择单个提交:
git cherry-pick A
- 选择单个提交,但停止进行修改:
git cherry-pick A -n
- 选择一系列提交:
git cherry-pick A..B
但是,如果我想选择一系列提交,但要修改每个提交,该怎么办?这不起作用:
git cherry-pick A..B -n
因为它停止了所有提交中的所有修改文件,所以如果我修改然后提交,所有更改都将合并到一个提交中。
樱桃采摘A..B后,您可以执行交互式重基础
git rebase ORIG_HEAD -i
然后从常规的交互式rebase命令中选择要执行的操作:
Commands:
p, pick = use commit
r, reword = use commit, but edit the commit message
e, edit = use commit, but stop for amending
s, squash = use commit, but meld into previous commit
f, fixup = like "squash", but discard this commit's log message
x, exec = run command (the rest of the line) using shell