git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH] document the <tree ish> <file> blob reference syntax

From
Andy Whitcroft <apw@shadowen.org>
Date
Oct 25, 2006, 10:42 UTC
Message-ID
<38fafea491402334df335c486270ebe9@pinky>

It is possible to specify a specific file within a tree-ish symbolically. For example you can find the contents of a specific file in a specific commit as below:

	git cat-file -p v1.2.4:git-prune.sh

Document this syntax in the Symbolic Identifiers section of the main git documentation and reference it from git-cat-file's documentation.

Signed-off-by: Andy Whitcroft <apw@shadowen.org>
---
diff --git a/Documentation/git-cat-file.txt b/Documentation/git-cat-file.txt
index 5e9cbf8..9f2138d 100644
--- a/Documentation/git-cat-file.txt
+++ b/Documentation/git-cat-file.txt
@@ -19,7 +19,9 @@ or '-s' is used to find the object size.
 OPTIONS
 -------
 <object>::
-	The sha1 identifier of the object.
+	The sha1 identifier of the object or a symbolic object
+	reference.  See the Symbolic Identifiers section of the
+	main git manual page.
 
 -t::
 	Instead of the content, show the object type identified by
@@ -58,6 +60,18 @@ Otherwise the raw (though uncompressed) 
 be returned.
 
 
+EXAMPLES
+--------
+git cat-file -p c5a5d29aaacf753b70e715169cbb7f74f0193e4a::
+	Pretty print the object directly using an sha1, perhaps
+	from a git ls-tree output.
+
+git cat-file -p v1.2.4:git-prune.sh::
+	Output the file git-prune.sh from the branch or tag v1.2.4.
+	Note that where the name is ambigious a heads/ or tags/
+	prefix may be used to disambiguate the name.
+
+
 Author
 ------
 Written by Linus Torvalds <torvalds@osdl.org>
diff --git a/Documentation/git.txt b/Documentation/git.txt
index 7074e32..e9f99e2 100644
--- a/Documentation/git.txt
+++ b/Documentation/git.txt
@@ -565,6 +565,13 @@ HEAD::
 	a valid head 'name'
 	(i.e. the contents of `$GIT_DIR/refs/heads/<head>`).
 
+Some commands will also accept the following extended syntax:
+
+<tree-ish>:<file>::
+	indicating a specific blob for that file within the tree
+	object specified, which may also be symbolic.  For example
+	'v1.2.4:git-prune.sh'.
+
 
 File/Directory Structure
Next: Junio C Hamano
Message 1 of 5 in “document the <tree ish> <file> blob reference syntax”
  1. document the <tree ish> <file> blob reference syntaxAndy Whitcroft, Oct 25, 2006
  2. Junio C HamanoOct 25, 2006
  3. Andy WhitcroftOct 25, 2006
  4. Junio C HamanoOct 25, 2006
  5. Jakub NarebskiOct 25, 2006

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.