I almost exclusively use add -p. It's another moment to review my changes and it saves me from having to type out the names of the files I've changed. I don't know if I've ever committed a file unintentionally since adopting it.
I like it especially in concert with git commit --amend, which lets me tack my newest changes onto the previous commit. (Though an interactive rebase with fixup is even better)
> I don't know if I've ever committed a file unintentionally since adopting it.
I’ve had the opposite problem: forgetting to add new files.
> I like it especially in concert with git commit --amend, which lets me tack my newest changes onto the previous commit. (Though an interactive rebase with fixup is even better)
No need for the rebase to be interactive:
$ git commit --fixup=<commit>
$ git rebase --autosquash <base>
I occasionally forget to add a new file but don't mind it much. I consider it a significantly smaller problem than committing a file that shouldn't be. CI is gonna run and my tests are surely gonna fail if I didn't commit some file. So I'll see that and commit --amend or fixup to add the new file.
unless the file I forgot to commit is the tests, which hopefully I'll catch by the time of the PR
I like it especially in concert with git commit --amend, which lets me tack my newest changes onto the previous commit. (Though an interactive rebase with fixup is even better)