16

When I do an interactive rebase in git, how do I squash a commit and also stop end edit the same commit?

cambunctious
  • 8,391
  • 5
  • 34
  • 53
  • I had hoped to cleverly solve this by adding `edit HEAD` to the todo, referring to the newly squashed commit. But HEAD is resolved too early so it doesn't work :( – David Cook Aug 26 '21 at 01:54

2 Answers2

7

Do it in two steps, first squash and next in second run of interactive rebase edit squashed commit.

Slawomir Jaranowski
  • 7,381
  • 3
  • 25
  • 33
6

Alternatively, you could use 'edit' to edit the commit, and then do e.g.

git reset --soft HEAD^
git commit --amend
ObsequiousNewt
  • 260
  • 2
  • 5