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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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

> Heya,
> 
> On Wed, Apr 21, 2010 at 22:20, Sylvain Rabot <sylvain@xxxxxxxxxxxxxx> wrote:
>> 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

--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]