Another approach is possible with Git 2.11+ (Q4 2016)
git ls-files --recurse-submodules
See commit 75a6315 , commit 07c01b9 , commit e77aa33 , commit 74866d7 (October 7, 2016) Brandon Williams ( mbrandonw ) .
(merger of Junio C Hamano - gitster - at commit 1c2b1f7 , October 26, 2016)
ls-files : possibly recursion into submodules
" git ls-files " recognized " --recurse-submodules ", which can be used to obtain a list of monitored files through submodules (i.e. this only works with the --cached option, and not to list unplayable or ignored files).
This would be a useful tool for sitting on the side upstream of the channel, which is read using xargs to work with all the working files of the tree from a top-level superproject.
As shown in this test , the output will include the full path to the file, starting with the main parent repo.
The git ls-files documentation now includes:
--recurse-submodules
Recursively calls ls files on each submodule in the repository.
Currently, only -cached mode is supported.
Git 2.13 (Q2 2017) adds ls-files --recurse-submodules :
See commit 2cfe66a , commit 2e5d650 (April 13, 2017) by Jacob Keller ( jacob-keller ) .
(merged Junio C Hamano - gitster - in commit 2d646e3 , April 24, 2017)
ls-files : fix recurse-submodules with nested submodules
Since commit e77aa33 ("ls-files: it is not necessary to overwrite in submodules", 2016-10-07, Git 2.11) ls-files known as submodules when displaying files.
Unfortunately, this fails in some cases, including when nesting more than one submodule, called from within the submodule, which itself has submodules, or when the GIT_DIR environment variable is GIT_DIR .
Prior to committing b58a68c (" setup : allow the prefix to be passed to Git commands", 2017-03-17, Git 2.13-rc0), this led to an error indicating that --prefix and --super-prefix were incompatible.
After this commit, instead, the cycle loop is forever with the set of GIT_DIR for the parent and constantly reads the parent files of the submodules and is recursively maintained.
Fix this by properly preparing the environment for the submodules when setting up the child process. This is similar to how other commands, such as grep, behave.