git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: Question about "git commit -a"

From
PCPaolo Ciarrocchi <paolo.ciarrocchi@gmail.com>
Date
Oct 5, 2007, 09:06 UTC
Message-ID
<4d8e3fd30710050206h7a177472x7c92f91204b15aa4@mail.gmail.com>
In-Reply-To
<4705FB52.3030208@op5.se>
On 10/5/07, Andreas Ericsson <ae@op5.se> wrote:
Show 29 quoted lines
> Paolo Ciarrocchi wrote:
> > On 10/4/07, Johannes Schindelin <Johannes.Schindelin@gmx.de> wrote:
> >> Hi,
> >>
> >> On Fri, 5 Oct 2007, Nguyen Thai Ngoc Duy wrote:
> >>
> >>> On 10/4/07, Wincent Colaiuta <win@wincent.com> wrote:
> >>>>> Am I wrong?
> >>>> About it being a majority, yes, I suspect so.
> >>>>
> >>> Maybe in the next survey we should include question "do you usually do
> >>> 'git commit' or 'git commit -a'" :-)
> >> Not meaning to discourage you, but it is a known fact that Linus does "git
> >> commit" without "-a" quite often.
> >>
> >> And if that were not bad enough for your plan, I myself omit "-a"
> >> regularly.  So you would get a veto from me, too.
> >
> > So you are used to do something like (please correct me if I'm wrong):
> > - modify A
> > - modify B
> > - modify C
> > - modify D
> > - modify E
> >
> > $ git A B E
>
>
> This isn't really a valid command. I'm not sure where you got it from.

Doh! Don't consider it, it's just a silly copy and paste error! It has no meaning!

Show 10 quoted lines
> > $ git add A B E (A, B and E are now in the staging area)
> > $ git commit -m "I just modified A,B and E"
>
> I do something like that, except that for full-file commits I'd rather
> say
>
>         git commit -s A B E
>
> I never pass -m to git commit. It's too easy to get into habit of being
> sloppy with historic documentation that way.

Right. But in the scenario you described isn't enough to type "git commit -s". Why did you write "git commit -s A B E".

> > $ git C D
>
> Again not a valid command, but...
See above, just a very silly copy and paste error.
Show 15 quoted lines
> > $ git add C D (C and D are now in the staging area)
> > $ git commit -m "I just modified C and D"
> >
>
> See above :)
>
> There's also the times when I hack on some feature and find some small
> bug/easy-to-write-feature, so I make the change for that other thing,
> swap to a different branch and do 'git commit -s --interactive' to
> just break out that small fix.
>
> Or if I have to add some logic to some other function in a file I've
> modified for other purposes and want it to be two separate commits,
> I just make the change and then run 'git commit --interactive' to
> make it two separate commits.
Very interesting!
Show 5 quoted lines
> I just don't do 'git commit -a' for the same reason I don't do
> 'git commit -m', really. It tends to be habit-forming, and bisect
> has saved my arse enough times for me to *want* my changes to be
> small and isolated. Debugging a 5-line patch is so much more pleasant
> than debugging a 30k-lines one that spans over several different files.

Yeah, I see. Thanks for your comments Andreas, very appreciated.

Just to clarify my goal, since I had that interesting discussion with an hg user I started looking for simple examples of the usage of the "staging area" to be added to the introduction to git documentation. The role of the index/staging area seems to be something complex for a git newbie.

Regards
-- 
Paolo
http://paolo.ciarrocchi.googlepages.com/
http://ubuntista.blogspot.com
Previous: Andreas EricssonNext: Andreas Ericsson
Message 11 of 35 in “Question about "git commit -a"”
  1. Paolo CiarrocchiOct 4, 2007
  2. Matthieu MoyOct 4, 2007
  3. Paolo CiarrocchiOct 4, 2007
  4. Wincent ColaiutaOct 4, 2007
  5. Nguyen Thai Ngoc DuyOct 4, 2007
  6. Johannes SchindelinOct 4, 2007
  7. Nguyen Thai Ngoc DuyOct 4, 2007
  8. Shawn O. PearceOct 4, 2007
  9. Paolo CiarrocchiOct 5, 2007
  10. Andreas EricssonOct 5, 2007
  11. Paolo CiarrocchiOct 5, 2007
  12. Andreas EricssonOct 5, 2007
  13. Matthieu MoyOct 5, 2007
  14. Andreas EricssonOct 5, 2007
  15. Matthieu MoyOct 5, 2007
  16. Andreas EricssonOct 5, 2007
  17. Paolo CiarrocchiOct 5, 2007
  18. Andreas EricssonOct 5, 2007
  19. Matthieu MoyOct 5, 2007
  20. Kristian HøgsbergOct 5, 2007
  21. Matthieu MoyOct 5, 2007
  22. Marko MacekOct 5, 2007
  23. Andy ParkinsOct 6, 2007
  24. Linus TorvaldsOct 6, 2007
  25. Wincent ColaiutaOct 7, 2007
  26. Dmitry PotapovOct 5, 2007
  27. Marko MacekOct 7, 2007
  28. Dmitry PotapovOct 7, 2007
  29. Johannes SchindelinOct 7, 2007
  30. Wincent ColaiutaOct 5, 2007
  31. Andy ParkinsOct 4, 2007
  32. Miles BaderOct 5, 2007
  33. David SoriaOct 4, 2007
  34. Alex RiesenOct 4, 2007
  35. Johannes SchindelinOct 4, 2007

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.