Re: Option for "git submodule foreach" to also run on the parent git?
- From
D. Ben Knoble <ben.knoble@gmail.com>
- Date
- Mar 9, 2026, 22:14 UTC
- Message-ID
- <CALnO6CCR1BioeC_eYCBt9BCrFS63L6f_5p2nTk=Z9eOAj3hW1A@mail.gmail.com>
- In-Reply-To
- <032a7767-2350-4312-a7b1-75080519c72a@nutanix.com>
On Mon, Mar 9, 2026 at 8:56 AM Florian Schmidt <flosch@nutanix.com> wrote:
Show 24 quoted lines
> > Hey everyone, > > would there be an appetite for a new option to "git submodule foreach" > to run the foreach command on the parent git repo as well? > > I occasionally use "git submodule foreach", for example, to make dev > branches on all the submodules if I expect to touch them all during a > dev cycle. Even if I don't need them on all submodule, once I'm done > with everything, I might run something like "git submodule foreach 'git > branch -d <foo> || :'" for easy cleanup. > > In either case, I likely also want to run the same command on the parent > git. That's easily achieved by just running it manually one more time, > and I'm sure it's not hard to make a git alias for that either. But I > wonder whether the workflow is common enough that there's interest in > adding a command-line option for that? I'd be happy to have a look in > that case. > > Also, tangentially related, "|| :" works, but what about a command line > option to continue on non-zero return values and not abort? > > Cheers, > Florian
This is not particularly general-purpose, but don't we have submodule.recurse (-> switch, checkout) and submodule.propagateBranches to make this kind of branching workflow easier?
-- D. Ben Knoble