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

Re: Question about "git commit -a"

From
Linus Torvalds <torvalds@linux-foundation.org>
Date
Oct 6, 2007, 16:13 UTC
Message-ID
<alpine.LFD.0.999.0710060903310.23684@woody.linux-foundation.org>
In-Reply-To
<200710060843.38567.andyparkins@gmail.com>
On Sat, 6 Oct 2007, Andy Parkins wrote:
> 
> Who cares?  Commits that build isn't the only reason for small commits.

More importantly, while it's true that you should always test all your changes, quite often they really *are* obviously separate.

I've mentioned this as an example lots of times, but I often tend to have multiple independent things in my tree at the same time. One of the "clearly independent" ones is the fact that I historically tended to update my Makefile for the next version number several days before I do the actual release, just to remind me (I used to forget to bump the version number, so..).

So I often have a dirty main makefile, but that doesn't mean that I'm going to commit it until I'm ready. I want to (no - *need* to) be able to pull and apply patches from other people despite the fact that I have some dirty state.

[ It's not just the makefile: almost all of what I do these days is pull 
  and apply patches, but I also send out suggestions to other developers 
  by email, and I often end up keeping my suggestion around in my tree as 
  dirty state. I could use a topic branch, but the thing is, I don't 
  actually want to save it - but not only do I actually like seeing the 
  "couldn't merge due to dirty state" because that tells me I got the fix 
  back, but I like just eatign my dogfood and compiling the kernel with 
  the suggestions I sent out ]

So it's quite ok to have multiple independent changes going on it the tree, and there's absolutely *zero* reason to think you should commit them together (quite the reverse). Maybe this isn't all that common for a *small* thing, but I pretty much guarantee that large projects always end up doing somethng like this.

And making the *default* workflow do something bad - namely commit everything blindly - is not a good idea. I'd rather have the normal workflow basically try to encourage many small commits, because while it's true that they may not have been tested individually, 99% of the time any linkages are pretty obvious.

(Side note: the *most* common failure to check stuff in completely tends to be one that other SCM's also have, for all the same reasons: forgetting to *add* a new file. I suspect the git model of "add all new changes" whether new files or old, actually _helps_ avoid that error, but quite frankly, I don't think we'll ever get away from it. It's just too easy a mistake to do).

			Linus
Previous: Andy ParkinsNext: Wincent Colaiuta
Message 24 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.