threads / discuss / 16931

Extracting a single commit or object

Subject: Extracting a single commit or object

## tl;dr

6 messages between Dec 30, 2008 and Jan 2, 2009.

replies: 5people: 5as markdown or json

yitzhakbg· Dec 30, 2008, 22:15 UTC · lore

How would I extract a single commit from a repository by it's SHA1 (or any other treeish)? For that matter, how is any one single object extracted? Examples please. Thanks, YBG

-- 
View this message in context: http://www.nabble.com/Extracting-a-single-commit-or-object-tp21223948p21223948.html
Sent from the git mailing list archive at Nabble.com.
Shawn O. Pearce· Dec 30, 2008, 22:21 UTC · re: yitzhakbg · lore

Re: Extracting a single commit or object

yitzhakbg <yitzhakbg@gmail.com> wrote:
> 
> How would I extract a single commit from a repository by it's SHA1 (or any
> other treeish)?
> For that matter, how is any one single object extracted? Examples please.
git cat-file $type $sha1
e.g.

git cat-file commit $commitsha1 git cat-file blob $blobsha1

If you need to inspect a tree, ls-tree is probably better:

git ls-tree $commitsha1 git ls-tree $treesha1

-- 
Shawn.
Alex Riesen· Jan 1, 2009, 22:06 UTC · re: Shawn O. Pearce · lore

Re: Extracting a single commit or object

2008/12/30 Shawn O. Pearce <spearce@spearce.org>:
Show 8 quoted lines
> yitzhakbg <yitzhakbg@gmail.com> wrote:
>>
>> How would I extract a single commit from a repository by it's SHA1 (or any
>> other treeish)?
>> For that matter, how is any one single object extracted? Examples please.
>
> git cat-file $type $sha1
>
git cat-file -p $sha1
Johannes Schindelin· Jan 1, 2009, 16:52 UTC · re: yitzhakbg · lore

Re: Extracting a single commit or object

Hi,
On Tue, 30 Dec 2008, yitzhakbg wrote:
> How would I extract a single commit from a repository by it's SHA1 (or 
> any other treeish)?
Your question is not precise enough to answer.  Are you looking for
- the commit message?
- the patch?
- all the files referenced by that commit?
- all the files _and revisions_ referenced by that commit?
The answer depends quite a lot on the question...
> For that matter, how is any one single object extracted? Examples please.
The user-friendly way to look at a tree is
	git show HEAD:Documentation/
or some such.  Likewise, you can inspect single blobs like this:
	git show HEAD:README

If you activated bash completion, you can even complete monsters like this:

	git show \
v1.5.3:v1.5.3:t/t4013/diff.diff-tree_--cc_--patch-with-stat_--summary_master

Hth, Dscho

Miklos Vajna· Jan 1, 2009, 18:08 UTC · re: Johannes Schindelin · lore

Re: Extracting a single commit or object

On Thu, Jan 01, 2009 at 05:52:49PM +0100, Johannes Schindelin <Johannes.Schindelin@gmx.de> wrote:
Show 5 quoted lines
> If you activated bash completion, you can even complete monsters like 
> this:
> 
> 	git show \
> v1.5.3:v1.5.3:t/t4013/diff.diff-tree_--cc_--patch-with-stat_--summary_master

Wow, that's really a monster. After removing the first leading v1.5.3:, it works. (If this is a bash completion bug, I can't reproduce.)

Johannes Schindelin· Jan 2, 2009, 17:37 UTC · re: Miklos Vajna · lore

Re: Extracting a single commit or object

Hi,
On Thu, 1 Jan 2009, Miklos Vajna wrote:
Show 9 quoted lines
> On Thu, Jan 01, 2009 at 05:52:49PM +0100, Johannes Schindelin <Johannes.Schindelin@gmx.de> wrote:
> > If you activated bash completion, you can even complete monsters like 
> > this:
> > 
> > 	git show \
> > v1.5.3:v1.5.3:t/t4013/diff.diff-tree_--cc_--patch-with-stat_--summary_master
> 
> Wow, that's really a monster. After removing the first leading v1.5.3:, 
> it works. (If this is a bash completion bug, I can't reproduce.)
Heh, it's just another proof that copy-n-paste ist just error-prone.

Thanks, Dscho

← back to recent threads