Re: [FAQ?] Rationale for git's way to manage the index
- From
Junio C Hamano <junkio@cox.net>
- Date
- May 6, 2007, 17:43 UTC
- Message-ID
- <7vvef5c0fw.fsf@assigned-by-dhcp.cox.net>
- In-Reply-To
- <vpqk5vlamav.fsf@bauges.imag.fr>
Matthieu Moy <Matthieu.Moy@imag.fr> writes:
Show 12 quoted lines
> You don't necessarily see your error from the file list: > > % vi foo.c > % git add foo.c > % vi foo.c > % git commit -m foo > [...] > create mode 100644 foo.c > % > > This commited the old content of foo.c, while I hardly see any > scenario where this is the expected behavior.
One reason why is because you are using "-m foo" (a very non-descriptive commit message that would not help anybody including yourself in the future). Try the above without giving such a bogus error message with "-m" to commit, but instead let it spawn your editor --- you would be doing that in real-life when you are doing anything nontrivial. Then notice what appears on the file list of "Changed but not updated" section.
A single liner "-m" is handy for "Oops, typofix in foo.c" kind of commit, but in such a case you literally would be changing only the typofix and won't have "edit foo.c; git add foo.c; edit foo.c; git commit" sequence anyway.
I think Linus explained quite well to correct your doubts in your original message, and I do not have anything to add.