Search code examples
gitgit-submodules

How to get name list for chaned files in specific git submodule?


A parent git repo contains several submodules, and the folder structure as belowing:

parent-dir
    src
    module-a
    module-b
    module-c
    module-spec

In one parent git commit, a submodule may have multi commits. How to get all file names that changed in module-spec contains in a parent commit?

Found this question but the answer do not work.


Solution

  • You can also use git ls-tree to get commits of the submodule registered in the superproject and run git diff directly in the submodule:

    prev_commit=`git ls-tree HEAD~ module-spec | awk '{print $3}'`
    curr_commit=`git ls-tree HEAD  module-spec | awk '{print $3}'`
    cd module-spec
    git diff --name-only $prev_commit $curr_commit