I don't understand how this happens. Before I commit I always, always read through my the staged area. A simple git diff --staged (I have it aliased as gds) is enough. I've been able to prevent this kind of thing every single time it has happened both professionally and in my own personal projects.