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

Re: Some advanced index playing

From
Linus Torvalds <torvalds@osdl.org>
Date
Dec 3, 2006, 20:40 UTC
Message-ID
<Pine.LNX.4.64.0612031236560.3476@woody.osdl.org>
In-Reply-To
<200612032011.25922.alan@chandlerfamily.org.uk>
On Sun, 3 Dec 2006, Alan Chandler wrote:
Show 9 quoted lines
> >
> > 	git ls-tree HEAD -- that-file | git update-index --index-info
> > 	git commit that-file
> 
> I don't quite understand this - maybe it should be
> 
> git ls-tree HEAD -- that-file | git update-index --index-info
> git commit
> git commit -a
Sure. It depends on which file you want to commit first.
If you want to commit "that-file" first, you do my sequence.

If you want to commit everything _but_ "that-file", you do the second sequence (which basically removes the changes to "that-file" from the index, then commits the index, and then with "git commit -a" commits the remaining dirty state, which is obviously those changes to "that-file" that you still had in the working tree).

> either I want to ONLY commit that file at the working tree state (and index 
> before these commands), or I want to commit ALL except this file (so I can 
> later come and commit just that file)
Right. If you do
	git ls-tree HEAD -- that-file | git update-index --index-info
	git commit that-file

you basically ONLY commit "that-file". You first reset it (in the index) to the old state, but that's just so that "git commit that-file" will now happily commit the current state (in the working tree) of "that-file".

So "git commit that-file" will basically _ignore_ your current index. Because you told "git commit" (by naming "that-file") that you _only_ wanted to commit "that-file". So whatever state you had in your current index doesn't matter at all - it will only look at the HEAD tree _and_ that single file that you specified.

Previous: Alan ChandlerNext: Junio C Hamano
Message 7 of 21 in “Some advanced index playing”
  1. Alan ChandlerDec 3, 2006
  2. Linus TorvaldsDec 3, 2006
  3. Junio C HamanoDec 3, 2006
  4. Alan ChandlerDec 3, 2006
  5. Jakub NarebskiDec 3, 2006
  6. Alan ChandlerDec 3, 2006
  7. Linus TorvaldsDec 3, 2006
  8. Junio C HamanoDec 4, 2006
  9. Jakub NarebskiDec 3, 2006
  10. Linus TorvaldsDec 3, 2006
  11. Junio C HamanoDec 3, 2006
  12. git-explainJunio C Hamano, Dec 5, 2006
  13. Jakub NarebskiDec 5, 2006
  14. Martin LanghoffDec 5, 2006
  15. Junio C HamanoDec 5, 2006
  16. Johannes SchindelinDec 5, 2006
  17. Junio C HamanoDec 5, 2006
  18. Carl WorthDec 6, 2006
  19. Johannes SchindelinDec 6, 2006
  20. Nicolas PitreDec 6, 2006
  21. Alan ChandlerDec 3, 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.