Subject: Re: Option for "git submodule foreach" to also run on the parent git?

From: Jeff King <[email-masked]>
Date: Mon, 9 Mar 2026 15:30:01 -0400

On Mon, Mar 09, 2026 at 05:43:14PM +0000, Florian Schmidt wrote:

> > but at that
> > point, wouldn't it be simpler to explain what you are doing as
> > 
> >      do-this . ;# do it here
> >      git submodule foreach do-this ;# do it there all over
> 
> That's basically what's I'm doing. I figured instead of doing "foo && git
> submodule foreach foo", a "git submodule foreach --also-parent foo" would be
> marginally neater. But I don't feel strongly about it.

These days we also have git-for-each-repo. It is primarily about running
a command in a set of otherwise unrelated repos. But I wonder if:

  git for-each-repo --submodules do-this

would be a natural fit as an alternative to "git submodule foreach"? And
then you can imagine a "--current" option to discover the current repo
and include it in the list. And then:

  git for-each-repo --submodules --current do-this

would do what you want.

I dunno. I do not have any need for this myself, but just thinking out
loud.

-Peff