git cherry-pick A
git cherry-pick A -n
git cherry-pick A..B
但是,如果我想选择一系列提交,但是修改每个提交,我该怎么办?这不起作用:
git cherry-pick A..B -n
因为它停止了所有已提交的所有提交的修改文件,所以如果我修改然后提交,所有更改将合并到一个提交中。
答案 0 :(得分:4)
挑选A..B之后,您可以执行交互式rebase
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