commit:path/to/file
描述特定提交处的文件(“BLOB”)。例如在 git.git 存储库中:
$ git rev-parse v2.31.1:git.c
9bc077a025cba4c5b3628b0eabb4d3aac0f35c63
$ git cat-file -t 9bc077a025cba4c5b3628b0eabb4d3aac0f35c63
blob
$ git cat-file -p 9bc077a025cba4c5b3628b0eabb4d3aac0f35c63 | head
#include "builtin.h"
#include "config.h"
#include "exec-cmd.h"
#include "help.h"
#include "run-command.h"
#include "alias.h"
#include "shallow.h"
#define RUN_SETUP (1<<0)
#define RUN_SETUP_GENTLY (1<<1)
您可以在手册页的Specifying Revisions部分下找到解释:rev-parse
<rev>:<path>, e.g. HEAD:README, master:./README
A suffix : followed by a path names the blob or tree at the given
path in the tree-ish object named by the part before the colon. A
path starting with ./ or ../ is relative to the current working
directory. The given path will be converted to be relative to the
working tree’s root directory. This is most useful to address a blob
or tree from a commit or tree that has the same tree structure as the
working tree.
当然,path/to/file
可能是一个目录,在这种情况下,输出哈希将指向一个树对象。