What I have tried
git submodule foreach git checkout main
git submodule foreach git add --all
git submodule foreach git diff-index --quiet HEAD || git commit -m "%CommitMessage%"
git submodule foreach git push
This runs command 1 for all submodules, then command 2 for all submodules, etc.
What I would like
I would like to only have one foreach, and do all of the commands for a submodule at once, then move on to the next submodule.
Question
Is there a way to have the git submodule foreach call a method, or in some way call multiple commands at once?
I want to do this within a batch script on Windows.
git submodule foreach, I think the batch-file tag is appropriate, and I have restored it.%CommitMessage%and potentially||should make absolutely no difference. The question is clear "Is there a way to have the git submodule foreach call a method, or in some way call multiple commands at once?". Batch files are irrelevant to that, and a distraction, or potentially another question after this one has been answered.git submodule foreach. Explicitly spelling outcmd.exe/ batch-file solutions is important forgitcommands in general, whose sample commands are often written for POSIX-compatible shells, but especially when you have a mix of shell syntaxes, as in this case.batch-fileandbashtags are now appropriate. I have flagged your tag removal for moderator review - nothing personal, I just think the removal was the wrong thing to do.