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
RSRobert Shearman <rob@codeweavers.com>
Date
Nov 30, 2006, 21:33 UTC
Message-ID
<456F4E38.50001@codeweavers.com>
In-Reply-To
<87hcwgu5t1.wl%cworth@cworth.org>
Carl Worth wrote:
Show 10 quoted lines
> If the "create file; git add; edit file; git commit" confusion isn't
> blisteringly obvious to the git maintainers then I think I have to
> give up here.
>
> And this isn't just CVS-induced brain damage. It's the user being
> required to mentally juggle 3 states for the file, (the last
> "committed" state, the current "working tree" state, and this
> "something else" state). The sequence above, (which is very natural),
> exposes this "something else" state that to a new user.
>   

Exactly. We had a tutorial for the project I contribute to (admittedly the initial users were all used to how CVS worked) and while a number of people got the concept of the index and were fairly happy with it, it did add to the confusion of the tutorial, so now it doesn't mention the index at all.

The tutorial introduced it as a staging area for commits, but the trouble is that once you work like this you have to remember that "git-diff" won't show you what will be committed, so you have to use "git-diff-index" as well. If you get them mixed up then you end up committing the wrong thing.

Here's a selected list of the commands introduced in the tutorial, without mentioning the index: git diff git commit -a git commit <changed-files> git reset HEAD^ git cherry-pick

Here would be the same entries, but introducing the index too: git-update-index git diff git diff-index git commit git commit -a git commit <changed-files> git reset HEAD^ git reset --soft HEAD^ git cherry-pick git cherry-pick -n

The tutorial then goes from having ~12 common commands to learn up to ~17.
Show 8 quoted lines
> If we imagine a new user as coming, not from cvs, but coming from
> no revision control system, then it's less confusing to add one single
> new state, (the "last committed" state), in addition to the "working
> tree" state the user is familiar with.
>
> Forcing the user to learn two instead of one is just plain harder,
> (which is completely separate from git _allowing_ this extra state
> once you learn it).

Having the index exposed for even simple operations means that the user has to initially learn three states instead of two. The worst thing about the index is that it is a limbo state. The committed content is in the history and can be viewed by gitk (and other tools that the user will be introduced to later) and the working tree is exactly what the user sees in their editor. Having a hidden state isn't very good from an HCI point of view.

Once you understand the concept of the index, it is very useful. However, new users should be shielded from it if at all possible.

I'm not advocating making "git-commit" equal to "git-commit -a" as I've been frustrated by command's semantics changing in git before. I can understand long-time git users would automatically try to use "git-commit" to just commit their index and get annoyed if it did something unexpected. Therefore, I would advocate there being no default behaviour for "git-commit" except for displaying a help message, and making previous "git-commit" users now use "git-commit -i".

-- 
Rob Shearman
Previous: Alan ChandlerNext: Jakub Narebski
Message 68 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.