Git squash vs soft reset
/ 1 min read
I only found out less than a year ago. Many people use squash to have more control, but soft reset is much simpler specifically if using something like lazygit.
Lazygit flow
In lazygit I:
- Select a commit on the commits pane
- Press
gthens(for soft reset) - All the commits above the selected one go into the staging area
- I press
cto create a new commit with the reset and I “squashed” a bunch of commits quickly
Quick lazygit commits
I use a lot of checkpoint commits. So I create a lot of commits called c because in lazygit after staging stuff I just press c + c + <enter> and in 3 strokes I’ve added a commit. This is especially useful with AI agents. Every working change after a prompt I commit.
And after some iterations I have a list of c named commits that I “squash” with a soft reset.
Comparison table
┌─────────────────┬─────────────────────┬─────────────────────┐│ │ Soft reset │ Squash (rebase -i) │├─────────────────┼─────────────────────┼─────────────────────┤│ Commit messages │ Lost │ Merged or editable │├─────────────────┼─────────────────────┼─────────────────────┤│ Granularity │ All-or-nothing │ Pick commits squash │├─────────────────┼─────────────────────┼─────────────────────┤│ Simplicity │ Simpler │ More control │└─────────────────┴─────────────────────┴─────────────────────┘