admin管理员组

文章数量:1295856

Where does git store the hash of a submodule that would be checked out if I did this?

git submodule update --init --recursive

I want to write a program that prints the expected hash and the current hash (as well as the submodule paths and the corresponding branch names) for all submodules for which the two hashes don't match.

Where does git store the hash of a submodule that would be checked out if I did this?

git submodule update --init --recursive

I want to write a program that prints the expected hash and the current hash (as well as the submodule paths and the corresponding branch names) for all submodules for which the two hashes don't match.

Share edited Feb 17 at 23:19 SU3 asked Feb 12 at 1:19 SU3SU3 5,4093 gold badges43 silver badges71 bronze badges 3
  • 1 stackoverflow/a/50395503/7976758 git rev-parse HEAD:path/to/submodule Found in stackoverflow/search?q=%5Bgit-submodules%5D+hash – phd Commented Feb 12 at 6:48
  • That is good to know. Normally, this would solve my problem, but I'm working on a company machine that runs an antivirus that makes spawning processes very slow. So, for a few hundred submodules, running git rev-parse HEAD:path/to/submodule for each one takes a while. I want to write a single program that would find these hashes on its own. Does anyone know where these are saved? I've tried reading .git/modules/Submodule/refs/remotes/origin/Branch, but that doesn't always give the same hash, or doesn't even exist for some submodules. – SU3 Commented Feb 12 at 18:25
  • 1 Turns out you can give git rev-parse multiple revisions as arguments and it'll parse them all in one process. That works for me. – SU3 Commented Feb 13 at 5:30
Add a comment  | 

1 Answer 1

Reset to default 1
git rev-parse revision:path/to/submodule

outputs the hash. revision can be anything pointing to a commit for which you want to learn the hash of the submodule: it can be HEAD, branch like master, a tag, a commit hash.

path/to/submodule is the path from repository root.

本文标签: Where to find the expected git submodule hashStack Overflow