* Cherry-pick particular object
@ 2006-03-28 16:31 Sébastien Pierre
[not found] ` <20060328163422.0981a743.seanlkml@sympatico.ca>
` (2 more replies)
0 siblings, 3 replies; 9+ messages in thread
From: Sébastien Pierre @ 2006-03-28 16:31 UTC (permalink / raw)
To: git
Hi all,
This is a newbie question.
I recently wanted to "cherry" pick a particular file from my git-managed project history. Using gitk, I identified which was the revision I wanted (95ba0c74e03874e8c1721b91f92f161e9061621f), and then using git ls-tree, I managed to get the id of the file I wanted (78132af26431e649a0f85f22dc27e5787d80700f).
Now, what I simply wanted was to do something like:
"get the file corresponding to 78132af26431e649a0f85f22dc27e5787d80700f and save it as myfile.txt"
How would one properly do that with core git ?
-- Sébastien
^ permalink raw reply [flat|nested] 9+ messages in thread[parent not found: <20060328163422.0981a743.seanlkml@sympatico.ca>]
* Re: Cherry-pick particular object
[not found] ` <20060328163422.0981a743.seanlkml@sympatico.ca>
@ 2006-03-28 21:34 ` sean
2006-03-28 17:23 ` Sébastien Pierre
2006-03-28 22:44 ` Linus Torvalds
0 siblings, 2 replies; 9+ messages in thread
From: sean @ 2006-03-28 21:34 UTC (permalink / raw)
To: Sébastien Pierre; +Cc: git
On Tue, 28 Mar 2006 11:31:07 -0500
Sébastien Pierre <sebastien@xprima.com> wrote:
> Hi all,
>
> This is a newbie question.
>
> I recently wanted to "cherry" pick a particular file from my
> git-managed project history. Using gitk, I identified which was
> the revision I wanted (95ba0c74e03874e8c1721b91f92f161e9061621f),
> and then using git ls-tree, I managed to get the id of the file I
> wanted (78132af26431e649a0f85f22dc27e5787d80700f).
>
> Now, what I simply wanted was to do something like:
>
> "get the file corresponding to 78132af26431e649a0f85f22dc27e5787d80700f
> and save it as myfile.txt"
>
> How would one properly do that with core git ?
If you used:
$ git cat-file -t 78132af2643
It would tell you that this object is of type "blob".
To see the contents of blobs you can do something like:
$ git cat-file blob 78132af2643
Sean
^ permalink raw reply [flat|nested] 9+ messages in thread* Re: Cherry-pick particular object
2006-03-28 21:34 ` sean
@ 2006-03-28 17:23 ` Sébastien Pierre
2006-03-28 22:44 ` Linus Torvalds
1 sibling, 0 replies; 9+ messages in thread
From: Sébastien Pierre @ 2006-03-28 17:23 UTC (permalink / raw)
To: sean; +Cc: Git ML
On Tue, 28 Mar 2006 16:34:22 -0500
sean <seanlkml@sympatico.ca> wrote:
> If you used:
>
> $ git cat-file -t 78132af2643
>
> It would tell you that this object is of type "blob".
> To see the contents of blobs you can do something like:
>
> $ git cat-file blob 78132af2643
Thanks. That was exactly what I was looking for :)
-- Sébastien
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: Cherry-pick particular object
2006-03-28 21:34 ` sean
2006-03-28 17:23 ` Sébastien Pierre
@ 2006-03-28 22:44 ` Linus Torvalds
2006-03-28 22:54 ` Petr Baudis
1 sibling, 1 reply; 9+ messages in thread
From: Linus Torvalds @ 2006-03-28 22:44 UTC (permalink / raw)
To: sean; +Cc: Sébastien Pierre, git
On Tue, 28 Mar 2006, sean wrote:
>
> $ git cat-file -t 78132af2643
Side note: when using git-ls-tree, the "blob"ness information is already
in the tree output itself and you shouldn't even need to check the type
with "-t". So what is perhaps somewhat more interesting is actually the
mode of the file, since that determines whether the blob should be
interpreted as regular file content or as a symlink.
Ie you can have a tree like this:
100644 blob f2ba8f84ab5c1bce84a7b441cb1959cfc7093b7f abc
120000 blob f2ba8f84ab5c1bce84a7b441cb1959cfc7093b7f file
where the first one is a regular file called "abc" (which contains the
string "abc"), and the second is the _symlink_ that points to "abc".
They share the exact same blob, and what distinguishes them is the
filemode info from git-read-tree.
Of course, the symlink case isn't very common and likely not very
interesting in this case, but the fact that "git ls-files" is set up so
that you can just cut-and-paste the "blob <sha1-of-blob" part and feed it
to git-cat-file was definitely not just coincidence.
(A number of the early stuff was set up so that I could do things by hand
by just doing cut-and-paste of the output of the previous command. Git has
come a long way in the last 12 months ;)
Linus
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: Cherry-pick particular object
2006-03-28 22:44 ` Linus Torvalds
@ 2006-03-28 22:54 ` Petr Baudis
2006-03-28 23:24 ` Linus Torvalds
0 siblings, 1 reply; 9+ messages in thread
From: Petr Baudis @ 2006-03-28 22:54 UTC (permalink / raw)
To: Linus Torvalds; +Cc: sean, Sébastien Pierre, git
Dear diary, on Wed, Mar 29, 2006 at 12:44:02AM CEST, I got a letter
where Linus Torvalds <torvalds@osdl.org> said that...
> Ie you can have a tree like this:
>
> 100644 blob f2ba8f84ab5c1bce84a7b441cb1959cfc7093b7f abc
> 120000 blob f2ba8f84ab5c1bce84a7b441cb1959cfc7093b7f file
>
> where the first one is a regular file called "abc" (which contains the
> string "abc"), and the second is the _symlink_ that points to "abc".
>
> They share the exact same blob, and what distinguishes them is the
> filemode info from git-read-tree.
Huh? Didn't you rather want to say that "file" will point to a blob
containing just the "abc" string (the symlink target)? ;-)
--
Petr "Pasky" Baudis
Stuff: http://pasky.or.cz/
Right now I am having amnesia and deja-vu at the same time. I think
I have forgotten this before.
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: Cherry-pick particular object
2006-03-28 22:54 ` Petr Baudis
@ 2006-03-28 23:24 ` Linus Torvalds
2006-03-28 23:28 ` Petr Baudis
0 siblings, 1 reply; 9+ messages in thread
From: Linus Torvalds @ 2006-03-28 23:24 UTC (permalink / raw)
To: Petr Baudis; +Cc: sean, Sébastien Pierre, git
On Wed, 29 Mar 2006, Petr Baudis wrote:
> Dear diary, on Wed, Mar 29, 2006 at 12:44:02AM CEST, I got a letter
> where Linus Torvalds <torvalds@osdl.org> said that...
> > Ie you can have a tree like this:
> >
> > 100644 blob f2ba8f84ab5c1bce84a7b441cb1959cfc7093b7f abc
> > 120000 blob f2ba8f84ab5c1bce84a7b441cb1959cfc7093b7f file
> >
> > where the first one is a regular file called "abc" (which contains the
> > string "abc"), and the second is the _symlink_ that points to "abc".
> >
> > They share the exact same blob, and what distinguishes them is the
> > filemode info from git-read-tree.
>
> Huh? Didn't you rather want to say that "file" will point to a blob
> containing just the "abc" string (the symlink target)? ;-)
Well no, maybe I should have called the first file something else.
Both "abc" and "file" from a git perspective have the same _contents_ (the
blob containing the data 'abc').
But the filemode means that those contents have totally different meaning.
For the pth "file", it means that it's a _symlink_ to "abc", while for the
path "abc" it's a regular file that just has the _contents_ "abc".
So the end _result_ of this is that "file" points to a file called "abc"
that also has the contents "abc", and "cat file abc" will result in
"abcabc".
IOW, this is the result of doing
echo -n abc > abc
ln -s abc file
and importing the mess into git.
Linus
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: Cherry-pick particular object
2006-03-28 23:24 ` Linus Torvalds
@ 2006-03-28 23:28 ` Petr Baudis
0 siblings, 0 replies; 9+ messages in thread
From: Petr Baudis @ 2006-03-28 23:28 UTC (permalink / raw)
To: Linus Torvalds; +Cc: sean, Sébastien Pierre, git
Dear diary, on Wed, Mar 29, 2006 at 01:24:13AM CEST, I got a letter
where Linus Torvalds <torvalds@osdl.org> said that...
> On Wed, 29 Mar 2006, Petr Baudis wrote:
>
> > Dear diary, on Wed, Mar 29, 2006 at 12:44:02AM CEST, I got a letter
> > where Linus Torvalds <torvalds@osdl.org> said that...
> > > Ie you can have a tree like this:
> > >
> > > 100644 blob f2ba8f84ab5c1bce84a7b441cb1959cfc7093b7f abc
> > > 120000 blob f2ba8f84ab5c1bce84a7b441cb1959cfc7093b7f file
> > >
> > > where the first one is a regular file called "abc" (which contains the
> > > string "abc"), and the second is the _symlink_ that points to "abc".
> > >
> > > They share the exact same blob, and what distinguishes them is the
> > > filemode info from git-read-tree.
> >
> > Huh? Didn't you rather want to say that "file" will point to a blob
> > containing just the "abc" string (the symlink target)? ;-)
>
> Well no, maybe I should have called the first file something else.
>
> Both "abc" and "file" from a git perspective have the same _contents_ (the
> blob containing the data 'abc').
Oh, I've totally missed the '(which contains the string "abc")' part,
sorry. Apparently it's time to sleep for me. :/
--
Petr "Pasky" Baudis
Stuff: http://pasky.or.cz/
Right now I am having amnesia and deja-vu at the same time. I think
I have forgotten this before.
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: Cherry-pick particular object
2006-03-28 16:31 Cherry-pick particular object Sébastien Pierre
[not found] ` <20060328163422.0981a743.seanlkml@sympatico.ca>
@ 2006-03-28 21:37 ` Shawn Pearce
2006-03-28 21:38 ` Tony Luck
2 siblings, 0 replies; 9+ messages in thread
From: Shawn Pearce @ 2006-03-28 21:37 UTC (permalink / raw)
To: Sébastien Pierre; +Cc: git
S?bastien Pierre <sebastien@xprima.com> wrote:
> Hi all,
>
> This is a newbie question.
>
> I recently wanted to "cherry" pick a particular file from my
> git-managed project history. Using gitk, I identified which was
> the revision I wanted (95ba0c74e03874e8c1721b91f92f161e9061621f),
> and then using git ls-tree, I managed to get the id of the file I
> wanted (78132af26431e649a0f85f22dc27e5787d80700f).
>
> Now, what I simply wanted was to do something like:
>
> "get the file corresponding to
> 78132af26431e649a0f85f22dc27e5787d80700f and save it as myfile.txt"
>
> How would one properly do that with core git ?
git cat-file blob 78132af26431e649a0f85f22dc27e5787d80700f >myfile.txt
--
Shawn.
^ permalink raw reply [flat|nested] 9+ messages in thread* Re: Cherry-pick particular object
2006-03-28 16:31 Cherry-pick particular object Sébastien Pierre
[not found] ` <20060328163422.0981a743.seanlkml@sympatico.ca>
2006-03-28 21:37 ` Shawn Pearce
@ 2006-03-28 21:38 ` Tony Luck
2 siblings, 0 replies; 9+ messages in thread
From: Tony Luck @ 2006-03-28 21:38 UTC (permalink / raw)
To: Sébastien Pierre; +Cc: git
> "get the file corresponding to 78132af26431e649a0f85f22dc27e5787d80700f and save it as myfile.txt"
>
> How would one properly do that with core git ?
$ git cat-file blob 78132af2643 > myfile.txt
-Tony
^ permalink raw reply [flat|nested] 9+ messages in thread
end of thread, other threads:[~2006-03-28 23:28 UTC | newest]
Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-03-28 16:31 Cherry-pick particular object Sébastien Pierre
[not found] ` <20060328163422.0981a743.seanlkml@sympatico.ca>
2006-03-28 21:34 ` sean
2006-03-28 17:23 ` Sébastien Pierre
2006-03-28 22:44 ` Linus Torvalds
2006-03-28 22:54 ` Petr Baudis
2006-03-28 23:24 ` Linus Torvalds
2006-03-28 23:28 ` Petr Baudis
2006-03-28 21:37 ` Shawn Pearce
2006-03-28 21:38 ` Tony Luck
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox