When I do an interactive rebase in git, how do I squash
a commit and also stop end edit
the same commit?
Changing the Last Commit: git commit --amend. The git commit --amend command is a convenient way to modify the most recent commit. It lets you combine staged changes with the previous commit instead of creating an entirely new commit.
If you need to amend the message for multiple commits or an older commit, you can use interactive rebase, then force push to change the commit history. On the command line, navigate to the repository that contains the commit you want to amend.
We'll address two different approaches to squashing commits: Interactive rebase: git rebase -i … Merge with the –squash option: git merge –squash.
Do it in two steps, first squash and next in second run of interactive rebase edit squashed commit.
Alternatively, you could use 'edit' to edit the commit, and then do e.g.
git reset --soft HEAD^
git commit --amend
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