在清理(即大部分压缩)某些更大功能的历史时,我经常遇到以下情况:
Commit A:
- change A.1
- change A.2
- change A.3
// EDIT: maybe some more commits
Commit B:
- change B.1
- change B.2
- change B.3
Run Code Online (Sandbox Code Playgroud)
假设现在我想转移change B.1使用交互式rebase提交A. 到目前为止我发现的唯一方法是:
rebase -ireset HEAD^然后add -p)rebase -i这需要两个rebase并且非常麻烦.另外,我必须在拆分时重写提交B的提交消息.
有没有更好/更有效的方法来实现这一目标?
可能不是一个显着的改进,但是
git rebase -i A^git cherry-pick --no-commit Bgit add -pgit commit --amendgit reset --hardgit rebase --continue将是另一种选择。