I’ve always been a fan of small, concise commits. I strive to make my commits as small and concise as possible.
However I often fail… Very often I commit and… discover that I yet again forgot to fix a typo. Or remove a blank line. Nothing major. But it’s pretty annoying to have every other commit log reading ‘fixed typo’ or ‘formatted code’.
With Git, I don’t have this problem anymore.
git add somefile
git commit ––amend
Tada! I just modified my last commit to include new changes.
The other option I like to use from time to time is the rebase interactive mode. I use it to merge various commits into one. It has more powerful uses (like removing commits entirely) but I never used these (yet).
git rebase -i origin