Thread (5 messages) flat view 5 messages, 4 authors, 2016-06-15

Re: Add warning when there are changes in the index and using -a with git commit

From: Wincent Colaiuta <hidden>
Date: 2016-06-15 22:48:41

El 21/04/2010, a las 23:21, Sverre Rabbelier escribió:
Heya,

On Wed, Apr 21, 2010 at 22:20, Sylvain Rabot [off-list ref] wrote:
quoted
Many times I had the bad reflex of doing a git commit -as -m "blah
blah" when I was willing to commit only things I had staged in the
index.
Me too, and I think I brought it up in the past and it was dismissed
as being too annoying, but I'm not sure. Either way, you can work
around it by creating your own 'git-co' wrapper that does the check
and use that instead of 'git commit'.
I think this is a tendency fostered by evil tutorials which start off by saying that people can use "git commit -a" in order to continue working in the same way they are used to from Subversion. (These tutorials do more harm than good, IMO. Counseling people to use "git commit -a" and live as though the index didn't exist is about the same as teaching newcomers to VIM that they should just stay in insert mode the whole time; it's encouraging bad habits that end up producing a limited awareness of and proficiency with the tool.)

I personally never make the mistake of accidentally including an "-a" in my "git commit" parameters, because for me "-a" is not something routine but actually quite the opposite: something extremely exceptional.

Without even really meaning to, I ended up training myself to only commit what's staged in the index, because early on I acquired the habit of always reviewing every single changed hunk by using "git add --patch" (in fact I use it so often that I've created an alias of "git patch" for it). There's no telling how many times this kind of last-minute hunk-by-hunk reviewing has saved me from committing bad code.

Cheers,
Wincent
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help