When I do an interactive rebase in git, how do I squash
a commit and also stop end edit
the same commit?
Asked
Active
Viewed 1,406 times
16

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 Answers
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
-
This is what I typically do. I have a git alias `undo = reset HEAD^`. – cambunctious Oct 16 '21 at 17:23