Sometimes I commit my changes and then suddenly remember that I forgot to add some comment or do some simple formatting, and having done that I do yet another commit. When it comes time to format a patch, I don’t want that “small changes” commit to become a separate patch. I want to take the last two commits and merge them to one patch as if they were a diff between current state and before I started committing.
Googling the issue didn’t help. How do I do this?
If you haven’t pushed your changes, use interactive git rebase and mark those commits as fixup:
Alternatively, if you discover you forgot some changes right after committing, add that change to the index and use
git commit --amendto add it to your HEAD commit