Skip to contentSkip to conversation

Extracting a single commit or object

DISCUSSION yitzhakbg 5 participants 6 messages Jun 15, 2016

lore
Share & tools
lore

yitzhakbg

author
#0 lore raw

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

Signature · 2 lines
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.
#1 lore raw
Quoted 4 lines · yitzhakbg

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

Signature · 1 line
Shawn.
#2 lore raw

2008/12/30 Shawn O. Pearce <[email protected]>:

Quoted 8 lines
Quoted 4 lines · yitzhakbg

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

#3 lore raw
In reply to yitzhakbg

Hi,

Quoted 2 lines · yitzhakbg

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

Quoted 1 line

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

#4 lore raw
Quoted 5 lines · Johannes Schindelin

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

#5 lore raw

Hi,

Quoted 9 lines · Miklos Vajna
Quoted 5 lines · Johannes Schindelin

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