SushiHangover SushiHangover - 2 months ago 30
Git Question

Git - Chaining cmds (i.e. ls-files) to submodules

Is there a way to chain cmds to submodules within your repo? I am looking for built-in methods as I need this to be portable and without secondary installations.

In my case, I have a workflow pipeline that is based on ls-files (and log) and need to be able to see files that match certain conditions, even if they are in submodules.


git ls-files some/file/path/above/my/submodules/globed-file

Only shows files within the current repo and ignores the submodule's files.


June 2015: You can try to execute your command in each submodules, using git submodule foreach:

git submodule --quiet --recursive foreach "git ls-files yourFile"

One of the submodule will return something, if that file is present in it.

Note that with Git 2.11+ (Q4 2016), you can use instead:

git ls-files --recurse-submodules

See "finding a list of files (e.g. using git ls-files) including submodules".