Search code examples
gitgit-submodules

How can I find all references to a submodule in my repository


Is there any straight forward git command that I can use to get all the references of a submodule in my parent repo. Looking to find all gitlinks to a specified submodule in my parent repo. Something like git ls-tree that enlists all references.


Solution

  • Let's say the submodule X is referenced in commits a, b, c in the parent repo. I need to get a list of all these commits.

    You can for commits where X was added or deleted, using a diff filter:

    git log --diff-filter=AD -- X
    

    (note: X, not X/)

    Then you can list all commits between the one where X was introduced and the one where it was deleted

    git rev-list A ^B