Re: Add warning when there are changes in the index and using -a with git commit
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!