{"thread":{"id":"23555","subject":"Add warning when there are changes in the index and using -a with git commit","startedAt":"2010-04-21T20:20:35Z","lastAt":"2010-04-21T22:38:18Z","messageCount":5,"participants":["Sylvain Rabot","Sverre Rabbelier","Eli Barzilay","Wincent Colaiuta"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"140050","messageId":"v2m7fce93be1004211320r9adc0b14j11bd06c3b045e639@mail.gmail.com","threadId":"23555","inReplyTo":null,"subject":"Add warning when there are changes in the index and using -a with git commit","fromName":"Sylvain Rabot","fromEmail":"sylvain@abstraction.fr","sentAt":"2010-04-21T20:20:35Z","receivedAt":"2010-04-21T20:20:35Z","isPatch":false,"sender":{"key":"sylvain@abstraction.fr","avatar":"https://avatars.githubusercontent.com/u/153052?v=4"},"body":"Hi,\n\nMany times I had the bad reflex of doing a git commit -as -m \"blah\nblah\" when I was willing to commit only things I had staged in the\nindex.\n\nIt could be useful to add a warning and a prompt when using the -a\noption with changes staged in the index to avoid errors.\n\nRegards.\n\n-- \nSylvain\n"},{"id":"140057","messageId":"q2pfabb9a1e1004211421q80d273ady11f4621284522c46@mail.gmail.com","threadId":"23555","inReplyTo":"v2m7fce93be1004211320r9adc0b14j11bd06c3b045e639@mail.gmail.com","subject":"Re: Add warning when there are changes in the index and using -a with git commit","fromName":"Sverre Rabbelier","fromEmail":"srabbelier@gmail.com","sentAt":"2010-04-21T21:21:47Z","receivedAt":"2010-04-21T21:21:47Z","isPatch":false,"sender":{"key":"srabbelier@gmail.com","avatar":"https://avatars.githubusercontent.com/u/3098?v=4"},"body":"Heya,\n\nOn Wed, Apr 21, 2010 at 22:20, Sylvain Rabot <sylvain@abstraction.fr> wrote:\n> Many times I had the bad reflex of doing a git commit -as -m \"blah\n> blah\" when I was willing to commit only things I had staged in the\n> index.\n\nMe too, and I think I brought it up in the past and it was dismissed\nas being too annoying, but I'm not sure. Either way, you can work\naround it by creating your own 'git-co' wrapper that does the check\nand use that instead of 'git commit'.\n\n-- \nCheers,\n\nSverre Rabbelier\n"},{"id":"140060","messageId":"19407.28316.959251.348645@winooski.ccs.neu.edu","threadId":"23555","inReplyTo":"q2pfabb9a1e1004211421q80d273ady11f4621284522c46@mail.gmail.com","subject":"Re: Add warning when there are changes in the index and using -a with git commit","fromName":"Eli Barzilay","fromEmail":"eli@barzilay.org","sentAt":"2010-04-21T21:31:08Z","receivedAt":"2010-04-21T21:31:08Z","isPatch":false,"sender":{"key":"eli@barzilay.org","avatar":"https://avatars.githubusercontent.com/u/185905?v=4"},"body":"On Apr 21, Sverre Rabbelier wrote:\n> Heya,\n> \n> On Wed, Apr 21, 2010 at 22:20, Sylvain Rabot <sylvain@abstraction.fr> wrote:\n> > Many times I had the bad reflex of doing a git commit -as -m \"blah\n> > blah\" when I was willing to commit only things I had staged in the\n> > index.\n> \n> Me too, and I think I brought it up in the past and it was dismissed\n> as being too annoying, but I'm not sure. Either way, you can work\n> around it by creating your own 'git-co' wrapper that does the check\n> and use that instead of 'git commit'.\n\nI recently wrote a very quick script that I think is much better at\ndoing what svn users expect, but doesn't get in the way of doing more\ngit-ish things when they learn more git in the future.  IMO it works\nmuch better than the frequent advice I've seen in many places to just\nadd `-a' to `git commit'.  The only thing that this does is add \".\" if\nthere are no other paths mentioned as arguments.  Looks like in this\ncase git will add all files in the current directory, and commit them\ntogether with staged content in this directory -- which I think covers\neverythint that svn does.  I dropped this in my path as `git-ci':\n\n  #!/bin/sh\n  seen_path=no; for p; do if [ -e \"$p\" ]; then seen_path=yes; fi; done\n  if [ $seen_path = yes ]; then git commit \"$@\"; else git commit . \"$@\"; fi\n\n(Disclaimer: naive check, so if someone uses \"git ci -m .\" it will get\nconfused.  But it adds the \".\" in the beginning, so typos like\n\"git ci -m\" don't get broken.)\n\n-- \n          ((lambda (x) (x x)) (lambda (x) (x x)))          Eli Barzilay:\n                    http://barzilay.org/                   Maze is Life!\n"},{"id":"140069","messageId":"0CCBCCA0-8378-42A8-A925-F60AA09949DC@wincent.com","threadId":"23555","inReplyTo":"q2pfabb9a1e1004211421q80d273ady11f4621284522c46@mail.gmail.com","subject":"Re: Add warning when there are changes in the index and using -a with git commit","fromName":"Wincent Colaiuta","fromEmail":"win@wincent.com","sentAt":"2010-04-21T21:38:38Z","receivedAt":"2010-04-21T21:38:38Z","isPatch":false,"sender":{"key":"greg@hurrell.net","avatar":"https://avatars.githubusercontent.com/u/7074?v=4"},"body":"El 21/04/2010, a las 23:21, Sverre Rabbelier escribió:\n\n> Heya,\n> \n> On Wed, Apr 21, 2010 at 22:20, Sylvain Rabot <sylvain@abstraction.fr> wrote:\n>> Many times I had the bad reflex of doing a git commit -as -m \"blah\n>> blah\" when I was willing to commit only things I had staged in the\n>> index.\n> \n> Me too, and I think I brought it up in the past and it was dismissed\n> as being too annoying, but I'm not sure. Either way, you can work\n> around it by creating your own 'git-co' wrapper that does the check\n> and use that instead of 'git commit'.\n\nI 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.)\n\nI 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.\n\nWithout 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.\n\nCheers,\nWincent\n"},{"id":"140072","messageId":"w2r7fce93be1004211538pe406dfebs79e1f4673e521988@mail.gmail.com","threadId":"23555","inReplyTo":"0CCBCCA0-8378-42A8-A925-F60AA09949DC@wincent.com","subject":"Re: Add warning when there are changes in the index and using -a with git commit","fromName":"Sylvain Rabot","fromEmail":"sylvain@abstraction.fr","sentAt":"2010-04-21T22:38:18Z","receivedAt":"2010-04-21T22:38:18Z","isPatch":false,"sender":{"key":"sylvain@abstraction.fr","avatar":"https://avatars.githubusercontent.com/u/153052?v=4"},"body":"On Wed, Apr 21, 2010 at 23:38, Wincent Colaiuta <win@wincent.com> wrote:\n\n> 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.\n\nWell, the thing is I do that to but instinctively, 3 seconds after, I\ndo my git commit -as -m \"blah\", making useless the time I spend\nstaging hunks with git add -p\n\n-- \nSylvain\n"}]}