# Extracting a single commit or object

6 messages from 2008-12-30 to 2009-01-02. Participants: yitzhakbg, Shawn O. Pearce, Johannes Schindelin, Miklos Vajna, Alex Riesen.
Thread: https://gitlist.dev/t/16931

## yitzhakbg, 2008-12-30 22:15

Subject: Extracting a single commit or object
Message-ID: <21223948.post@talk.nabble.com>
URL: https://gitlist.dev/e/21223948.post%40talk.nabble.com

```

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, 2008-12-30 22:21

Subject: Re: Extracting a single commit or object
Message-ID: <20081230222106.GE29071@spearce.org>
URL: https://gitlist.dev/e/20081230222106.GE29071%40spearce.org
In-Reply-To: <21223948.post@talk.nabble.com>

```
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.

```

## Johannes Schindelin, 2009-01-01 16:52

Subject: Re: Extracting a single commit or object
Message-ID: <alpine.DEB.1.00.0901011747580.30769@pacific.mpi-cbg.de>
URL: https://gitlist.dev/e/alpine.DEB.1.00.0901011747580.30769%40pacific.mpi-cbg.de
In-Reply-To: <21223948.post@talk.nabble.com>

```
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, 2009-01-01 18:08

Subject: Re: Extracting a single commit or object
Message-ID: <20090101180834.GJ21154@genesis.frugalware.org>
URL: https://gitlist.dev/e/20090101180834.GJ21154%40genesis.frugalware.org
In-Reply-To: <alpine.DEB.1.00.0901011747580.30769@pacific.mpi-cbg.de>

```
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.)

```

## Alex Riesen, 2009-01-01 22:06

Subject: Re: Extracting a single commit or object
Message-ID: <81b0412b0901011406n13eb2fbarbed613785d9896f4@mail.gmail.com>
URL: https://gitlist.dev/e/81b0412b0901011406n13eb2fbarbed613785d9896f4%40mail.gmail.com
In-Reply-To: <20081230222106.GE29071@spearce.org>

```
2008/12/30 Shawn O. Pearce <spearce@spearce.org>:
> 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, 2009-01-02 17:37

Subject: Re: Extracting a single commit or object
Message-ID: <alpine.DEB.1.00.0901021836430.30769@pacific.mpi-cbg.de>
URL: https://gitlist.dev/e/alpine.DEB.1.00.0901021836430.30769%40pacific.mpi-cbg.de
In-Reply-To: <20090101180834.GJ21154@genesis.frugalware.org>

```
Hi,

On Thu, 1 Jan 2009, Miklos Vajna wrote:

> 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

```
