While cleaning up (i.e. mostly squashing) the history of some bigger feature, I often end up with the following situation:
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
Suppose that now I want to move change B.1
to commit A using an interactive rebase. The only way I have found so far to do this, is:
rebase -i
reset HEAD^
and then add -p
)rebase -i
This requires two rebases and is pretty cumbersome. Also I have to rewrite the commit message of commit B when splitting.
Is there any better/more efficient way to achieve this?
Probably not a significant improvement, but
git rebase -i A^
git cherry-pick --no-commit B
git add -p
git commit --amend
git reset --hard
git rebase --continue
would be another option.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With