git/list[1] front-page[2] threads[3] people[4] search[5] about
 

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
Previous: brian m. carlson
Message 6 of 6 in “Option for "git submodule foreach" to also run on the parent git?”
  1. Florian SchmidtMar 9, 2026
  2. Junio C HamanoMar 9, 2026
  3. Florian SchmidtMar 9, 2026
  4. Jeff KingMar 9, 2026
  5. brian m. carlsonMar 9, 2026
  6. D. Ben KnobleMar 9, 2026

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.