Re: How do get a specific version of a particular file?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 




On Tue, 27 Feb 2007, Theodore Ts'o wrote:
> 
> git-checkout will only write the output to the working tree.
> git-cat-file and git-show only work on a object identifier (they are
> low-level plumbing commands).  

Everybody has already pointed out how easy this actually is, but your 
fundamental mistake was thinking that "only work on a object identifier" 
is a bad thing.

Repeat after me: in git, *everything* is a SHA1 object!

So the problem you had was that "only". Remove the "only", and realize 
that object identifiers will cover _all_ you ever need, and be happy.

That's why

	git show <tree>:<path>

works. All the files are *also* just SHA1 objects, and as a result 
all the normal SHA1 naming rules apply.

This is also why you can literally do

	git diff v1.4.4:Makefile HEAD~5:Makefile

and it will just magically work and do exactly what the command line would 
make you think it does - even if you didn't know anything at all about 
git.

Because "git diff" knows about blob objects too, and "v1.3:Makefile" is 
the object name for the blob that was the Makefile object at version 
1.4.4, and HEAD~5:Makefile is the Makefile in the fifth parent of your 
current HEAD.

Tell me any other SCM that makes things quite _that_ easy?

So in Unix, we have "everything is a file" (and then we have processes). 
In git, we have "everything is a SHA1-named object" (and then we have 
revision walking). There's a really simple underlying logic to it all, and 
the great thing is how _powerful_ it is.

THIS is what good design is all about. Forget nipples. You just need to 
internalize the fact that "everything is a SHA1".

> So if it is a matter of we don't have an easy way to do this (as opposed
> to me being stupid or the git documentation just failing to mention it
> in the right places), what's the best way to add it?

So not only do we have it, it's probably not mentioned in the docs because 
it is *so* fundamental that nobody even thought to mention any of this 
except in the "how does SHA1 lookup work" sections.

			Linus
-
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]