I have a project with a lot of submodules and I want to delete all remote branches named foo in the submodules, if it exists.I am trying to following:git submodule foreach git push origin :fooThis works as intended if the branch exists in all submodules, but if any of the submodules is missing the branch, the foreach stops:Stopping at 'modules/bar'; script returned non-zero status.How do I suppress the error?
Remove branch from all submodules
git
From the git submodule man page:A non-zero return from the command in any submodule causes the processing to terminate. This can be overridden by adding || : to the end of the command.This means the following should do the job:git submodule foreach 'git push origin :foo || :'The || is an OR and executes the next command if the first one returns non-zero, the : returns true.