From: Junio C Hamano Date: Wed, 28 Jan 2009 21:29:36 GMT Subject: Re: (beginner) git rm Message-ID: <7vab9bm85b.fsf@gitster.siamese.dyndns.org> In-Reply-To: <1233175322729-2234796.post@n2.nabble.com> Zabre <427@free.fr> writes: > Björn Steinbrink wrote: >> >> The "git checkout -- d.txt" is also a valid command, but that restores >> the file from the index. >> >> git checkout -- paths >> ==> Copy "paths" from the index to the working tree >> >> git checkout -- paths >> ==> Copy "paths" from the tree-ish to the index and working tree >> >> So, for "rm d.txt", a plain "git checkout -- d.txt" would also do the >> trick, as d.txt is still in the index. But your "git rm d.txt" also >> removed the file from the index, and thus that checkout does nothing. >> But "git checkout HEAD -- d.txt" works, as it gets the file from HEAD >> and puts it into the index and working tree. > > This is enlightening, thank you very much! > (I knew I would love git more and more) > > Oh just one (probably stupid) thing : does represent a directory > being the root of a tree of folders (which has been added to the index), > does it? Yeah, it typically is a commit object. Björn said "Copy", but the operation really is like checking out a book from a library and "checkout" is a good word for it. "I do not like what I have in my work tree, and I'd like to replace it with a fresh one taken out of the index (or, out of that commit)".