Hi,
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.
It could be useful to add a warning and a prompt when using the -a
option with changes staged in the index to avoid errors.
Regards.
--
Sylvain
Heya,
On Wed, Apr 21, 2010 at 22:20, Sylvain Rabot [off-list ref] 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'.
--
Cheers,
Sverre Rabbelier
From: Eli Barzilay <hidden> Date: 2016-06-15 22:48:41
On Apr 21, Sverre Rabbelier wrote:
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 recently wrote a very quick script that I think is much better at
doing what svn users expect, but doesn't get in the way of doing more
git-ish things when they learn more git in the future. IMO it works
much better than the frequent advice I've seen in many places to just
add `-a' to `git commit'. The only thing that this does is add "." if
there are no other paths mentioned as arguments. Looks like in this
case git will add all files in the current directory, and commit them
together with staged content in this directory -- which I think covers
everythint that svn does. I dropped this in my path as `git-ci':
#!/bin/sh
seen_path=no; for p; do if [ -e "$p" ]; then seen_path=yes; fi; done
if [ $seen_path = yes ]; then git commit "$@"; else git commit . "$@"; fi
(Disclaimer: naive check, so if someone uses "git ci -m ." it will get
confused. But it adds the "." in the beginning, so typos like
"git ci -m" don't get broken.)
--
((lambda (x) (x x)) (lambda (x) (x x))) Eli Barzilay:
http://barzilay.org/ Maze is Life!
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
On Wed, Apr 21, 2010 at 23:38, Wincent Colaiuta [off-list ref] wrote:
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.
Well, the thing is I do that to but instinctively, 3 seconds after, I
do my git commit -as -m "blah", making useless the time I spend
staging hunks with git add -p
--
Sylvain