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

Re: [PATCH 0/2] Making "git commit" to mean "git commit -a".

From
Linus Torvalds <torvalds@osdl.org>
Date
Nov 30, 2006, 23:40 UTC
Message-ID
<Pine.LNX.4.64.0611301520370.3513@woody.osdl.org>
In-Reply-To
<7vlklsfsgz.fsf@assigned-by-dhcp.cox.net>
On Thu, 30 Nov 2006, Junio C Hamano wrote:
> 
> I sense that you are inviting me to argue for reverting the
> other "git commit" braindead which is spelled "--only" (and
> worse yet, it is the default).  I am very tempted.
I actually really like the current defaults for "git commit".

And I say that despite the fact that the defaults are _different_ from the original ones.

I like the fact that when you do "git commit filename", it really will commit _only_ that file, not the other files you added. It's logical.

So you can do
	echo a > file-a
	echo b > file-b
	git add file-a file-b
	git commit file-a

and it will only commit one of them. Now, admittedly, the status message that you get is slightly misleading (it says that "file-b" is untracked, which is not strictly true or at least somewhat confusing - it's untracked only within the context of that one commit), but this is all logically consistent.

And it's wonderful for noticing "Oh, sh*t, I forgot to commit that previous change, let's commit that other file first!". You can do things like this _despite_ the fact that you've added other files to the list of files to be committed.

The current semantics for "git commit" are really powerful, and really flexible. Yes, there are different "cases", but they all have their place:

 - "git commit" on its own:
    This is for things where you prepared things earlier: notably a merge, 
    for example. But it might be the "--amend" case too, where you simply 
    don't want to change any of the working tree, just the commit message.
   The fact that it has a nice fallback for the "nothing to commit" case 
   which basically just prints out the same thing as "git status" is just 
   gravy.
 - "git commit explicit/file anotherfile"
   This is great (and I use it) exactly for when you have random other 
   additions in your tree that are brewing, and you just want to commit a 
   particular fix that takes precedence. You may be in the middle of 
   something else, but you found a critical bug that needs to be fixed, 
   and while you _could_ do it on another branch, it's just a lot more 
   convenient to specify exactly what you want to commit.
 - "git commit -a"
   Sure, this is the common case, but just how painful is it to type those 
   extra few characters? And not defaulting to this is just sensible, 
   considering that "-a" really is not _that_ special, and the above two 
   cases simply aren't that unusual either. And it's just good to make 
   people have to _think_ about the fact that it commits everything that 
   have dirty.

At least for me, it turns out that the only mode I _never_ use personally is the "git commit -i" thing, which was actually the original behaviour, and which you'd think that I would encourage for that reason. But no. Of all the modes of "git commit", that's the one I think is the least important, and least interesting.

Of course, during a merge, you do need "-i" if you list files, but I think "-a" subsumes almost all cases (you _can_ use "-i file-list" or totally manually decide to have some extra edits you did that you don't want to commit together with the merge, but that's such a special case that I doubt anybody does it, so I don't think it's a big deal).

Anyway, we have "-i", and we don't force anybody to use it, so the fact that it's a bit odd and not that useful doesn't really matter. It certainly "fits" in the git commit family as another case, it's just not one of the important cases.

Previous: Junio C HamanoNext: Carl Worth
Message 54 of 76 in “Re: [PATCH 0/2] Making "git commit" to mean "git commit -a".”
  1. Junio C HamanoNov 29, 2006
  2. Nicolas PitreNov 29, 2006
  3. Junio C HamanoNov 29, 2006
  4. Nicolas PitreNov 29, 2006
  5. Jakub NarebskiNov 29, 2006
  6. Steven GrimmNov 29, 2006
  7. Jakub NarebskiNov 29, 2006
  8. Junio C HamanoNov 29, 2006
  9. Steven GrimmNov 29, 2006
  10. Johannes SchindelinNov 29, 2006
  11. Junio C HamanoNov 29, 2006
  12. xdl_merge(), was Re: [PATCH 0/2] Making "git commit" to mean "git commit -a".Johannes Schindelin, Nov 29, 2006
  13. Seth FalconNov 30, 2006
  14. Carl WorthNov 29, 2006
  15. Johannes SchindelinNov 29, 2006
  16. Junio C HamanoNov 30, 2006
  17. Junio C HamanoNov 30, 2006
  18. Steven GrimmNov 30, 2006
  19. Sam VilainNov 30, 2006
  20. Junio C HamanoNov 30, 2006
  21. Johannes SchindelinNov 30, 2006
  22. Linus TorvaldsNov 30, 2006
  23. Johannes SchindelinNov 30, 2006
  24. Andreas EricssonNov 30, 2006
  25. Linus TorvaldsNov 30, 2006
  26. Theodore TsoNov 30, 2006
  27. Linus TorvaldsNov 30, 2006
  28. Nicolas PitreNov 30, 2006
  29. Carl WorthNov 30, 2006
  30. Jakub NarebskiNov 30, 2006
  31. Carl WorthNov 30, 2006
  32. Andreas EricssonDec 1, 2006
  33. Han-Wen NienhuysDec 1, 2006
  34. Carl WorthNov 30, 2006
  35. Linus TorvaldsNov 30, 2006
  36. Nicolas PitreNov 30, 2006
  37. Linus TorvaldsNov 30, 2006
  38. Jakub NarebskiNov 30, 2006
  39. Carl WorthNov 30, 2006
  40. Michael K. EdwardsNov 30, 2006
  41. Carl WorthNov 30, 2006
  42. Jakub NarebskiNov 30, 2006
  43. Johannes SchindelinNov 30, 2006
  44. Josef WeidendorferNov 30, 2006
  45. Johannes SchindelinNov 30, 2006
  46. Nicolas PitreNov 30, 2006
  47. Nicolas PitreNov 30, 2006
  48. Junio C HamanoNov 30, 2006
  49. Andy ParkinsDec 1, 2006
  50. Alan ChandlerDec 1, 2006
  51. Junio C HamanoNov 30, 2006
  52. Nicolas PitreNov 30, 2006
  53. Junio C HamanoNov 30, 2006
  54. Linus TorvaldsNov 30, 2006
  55. Carl WorthDec 1, 2006
  56. Linus TorvaldsDec 1, 2006
  57. Carl WorthDec 1, 2006
  58. Linus TorvaldsDec 1, 2006
  59. Carl WorthDec 1, 2006
  60. Linus TorvaldsDec 1, 2006
  61. Carl WorthDec 1, 2006
  62. Michael K. EdwardsDec 1, 2006
  63. Junio C HamanoDec 1, 2006
  64. Jakub NarebskiDec 1, 2006
  65. Nicolas PitreDec 1, 2006
  66. Andreas EricssonDec 1, 2006
  67. Alan ChandlerDec 1, 2006
  68. Robert ShearmanNov 30, 2006
  69. Jakub NarebskiNov 30, 2006
  70. Shawn PearceDec 1, 2006
  71. Marco CostalbaDec 2, 2006
  72. Carl WorthNov 30, 2006
  73. Linus TorvaldsNov 30, 2006
  74. Daniel BarkalowNov 30, 2006
  75. Nicolas PitreNov 30, 2006
  76. Johannes SchindelinNov 30, 2006

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.