I have an extremely useful alias that I use extensively in my git workflow:
alias gfixup="git commit --fixup HEAD && EDITOR=cat git rebase -i --autosquash HEAD~2 | sed '/^#/ d'"
Commits changes in the git index and auto-squashes the commit into the previous commit without opening $EDITOR!
- git add .
- gfixup
(note: the rebase will fail if you still have modified files)
This is a very common development pattern
- Write some code and commit -m "did this thing"
- Test and discover a problem and make a new commit -m "fix the thing I just did"
Don't make sloppy commits like this any longer and always keep the head of your branch in a working state!