Where does Git store the SHA1 of the commit for a

2019-01-16 04:34发布

I know that when you add a submodule to a git repository it tracks a particular commit of that submodule referenced by its sha1.

I'm trying to find where this sha1 value is stored.

The .gitmodules and .git/config files only show the paths for the submodule, but not the sha1 of the commit.

The git-submodule(1) reference only speaks of a gitlink entry and the gitmodules(5) reference doesn't say anything about this either.

1条回答
地球回转人心会变
2楼-- · 2019-01-16 05:22

It is stored in Git's object database directly. The tree object for the directory where the submodule lives will have an entry for the submodule's commit (this is the so-called "gitlink").

Try doing git ls-tree master <path-to-directory-containing-submodule> (or just git ls-tree master if the submodule lives in the top-level directory).

查看更多
登录 后发表回答