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, 17:13 UTC
Message-ID
<Pine.LNX.4.64.0611300903080.3513@woody.osdl.org>
In-Reply-To
<20061130164046.GB17715@thunk.org>
On Thu, 30 Nov 2006, Theodore Tso wrote:
>
> But then why is the default for "git commit" to commit the index, if
> the index is almost == HEAD?  And why is git-update-index given such
> prominence in the documentation?
The default is: commit everything that you ask for to be committed.

If you haven't marked anything to be committed (which you can do with "git add" too, or with simply being in the middle of a merge, or by having done something like "git pull -n" or similar that does everything _but_ commit), then git commit will say "nothing to do".

It has NOTHING to do with the index per se. 
I still don't understand why people are so hung up about the index.
So ignore the index entirely, and follow along with me:
	"git commit" with no parameters simply DOES NOT DO ANYTHING YOU 
	HAVEN'T ALREADY ASKED YOU TO DO.

It's that simple. It's that logical. Ignore the index. Ignore everything else. Just read that simple, straightforward, and logical sentence on its own. It all makes sense.

Then, the trivial follow-up is:
	If you want to commit _all_ dirty files, use "git commit -a". 
	Otherwise, name the files or subdirectories you want to commit 
	explicitly.
Again: THIS JUST MAKES SENSE.
Asking for "-a" to be the default behaviour is BAD.

For example, in "git commit --amend", it's _important_ that "-a" not be the default, because you may well want to just amend the commit _message_. No files updated AT ALL. You may have other state that is still dirty (because you didn't ask it to be committed last time), and they should NOT be committed, because the simple rule is:

	"git commit" with no parameters simply DOES NOT DO ANYTHING YOU 
	HAVEN'T ALREADY ASKED YOU TO DO.
Repeat the above sentence again. IT JUST MAKES SENSE.

So maybe the documentation shouldn't mention the "index" at all, because it apparently scares and confuses people. But the fact is, the documentation started out as _technical_ documentation, that explains the _technical_ side of git. We don't have lots of "end-user" docs.

But the lack of such end-user documentation should not cause idiotic threads like this, where people blame "the index".

Yeah, so the docs are too scary. But none of this has anything to do with "the index". It's all logical on its own, and the default behaviour to not commit anything you haven't asked to be committed is the right one.

Make "git commit" just say "You didn't say what you wanted to commit. Maybe you meant 'git commit -a'" if there's nothing to commit. How hard can that be? But don't change semantics now, and please DO NOT change them to something _worse_ than what we have now (and automatically adding the "-a" only in _certain_ circumstances is definitely much worse imnsho)

Previous: Theodore TsoNext: Nicolas Pitre
Message 27 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.