4

Is there anyway to tell git submodule foreach to run in the submodule order specified in the .gitmodules? It seems to run alphabetically.

I want to the foreach command to run in th same order the submodules were added.

DarVar
  • 16,882
  • 29
  • 97
  • 146
  • Is creating a bash script to feed correctly-ordered submodules to `git submodule update` a non-starter? [This question](http://stackoverflow.com/q/14846967/2449857) discusses the theme. – Jack Deeth Dec 16 '16 at 20:13

1 Answers1

2

It seems there is no solution using git but a simple line of bash makes the job:

You extract the list of submodules with sed, then you read it line by line and execute what you want.

cat .gitmodules | sed -n 's/.*path = //p' | { while read project; do  everything you want execute with each $project; done; }

It respects the order that was in your gitmodules file

Arnaud B.
  • 151
  • 1
  • 7