1

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.

i.e.

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

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

Nick Volynkin
  • 14,023
  • 6
  • 43
  • 67
SushiHangover
  • 73,120
  • 10
  • 106
  • 165

1 Answers1

4

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".

Community
  • 1
  • 1
VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
  • Thanks, I've used foreach on the submodule option, it of course does not include the process on the git repo files containing those submodules. This is the only answer I could could come up with also, I'll just have to run multiple cmds and place the union of those results on the bash pipeline. – SushiHangover Jun 30 '15 at 21:51