I've been familiarizing myself a bit more with git internals and the different git objects. I have a simple repository with one .txt file in the top directory, two .txt files (file1.txt and file2.txt) in a directory called 'my-directory' and a submodule called 'my-submodule'. I get an error when I try to run $ git cat-file -p {submodule git commit object SHA-1}
and I'm unable to figure out why. I'm showing all the commands I'm running, below and hope someone can help me out.
$ git cat-file -p master
tree fcc88590212b42b31803217036a93a9edfe4af1c
parent ae767cc2edd396e63f127d4f3354f769645a3dc4
author Martin
committer Martin
Awesome commit
$ git cat-file -p fcc88590212b42b31803217036a93a9edfe4af1c
100644 blob 21735012b86a0c6c266eb7fb629a777ca70848c1 my-file.txt
040000 tree 4df930165b3c59c0f5dc134ed76d889e4d177d2f my-directory
160000 commit 93a431b481f9ca2b498c94b0c0641e54f00322e0 my-submodule
$ git cat-file -p 21735012b86a0c6c266eb7fb629a777ca70848c1
This is the content of 'my-file.txt'
$ git cat-file -p 4df930165b3c59c0f5dc134ed76d889e4d177d2f
100644 file1.txt
100644 file2.txt
$ git cat-file -p 93a431b481f9ca2b498c94b0c0641e54f00322e0
fatal: Not a valid object name 93a431b481f9ca2b498c94b0c0641e54f00322e0
The cat-file
shows you objects from current repository, but a submodule it is a separate repository. So, the commit-id 93a43…
is a commit from a different object storage. You should navigate to submodule's directory and try from there:
$ cd my-submodule
$ git cat-file -p 93a431b481f9ca2b498c94b0c0641e54f00322e0
I imagine git figures out that a particular tree entry is a submodule by type of object. Ie if an entry type is a:
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.