Move changes to a different commit when interactive rebasing

Viewed 1151

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:

  1. Start rebase -i
  2. Edit commit B
  3. Split commit B in tmp commit and commit B (reset HEAD^ and then add -p)
  4. Start rebase -i
  5. Fixup tmp commit in commit A

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?

1 Answers
Related