Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

How to search for a Git commit in submodules?

I have a repo with multiple submodules. I have a commit’s hash but do not know to which submodule it belongs, how I could find it’s exact submodule?

>Solution :

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

Run git show in all submodules, recursively; hide error messages, ignore errors; report the submodule when the hash is found (git show doesn’t return error):

git submodule foreach -q --recursive 'git show -q $hash 2>/dev/null && echo $name || :'

See the docs.

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading