git -submodules / repo – How to use commit and branch for a bunch of branches in separate modules?

I have repo wrapper and about dozen different git repositories in it.

I would like to have one patch which I can apply/use later
in the following manner:

I would like to perform this commands on all the changed submodules:

git checkout -b all_sub_branch
git commit -a all_submodules
git format-patch all_submodules aaa.patch
git apply aaa.patch

  • git - Is it possible to exclude file from `git push`, but keep them in the local repository?
  • Github file history doesn't show all my commits
  • Moving Git repository content to another repository preserving history
  • how to fetch the old code from git repository
  • Difference between git@github.com:… and https://github.com/…?
  • How to Link 1 git repository to some other repositories?
  • How can I delete (or merge) a local Git branch that I'm currently on?
  • How to move svn folder one level up
  • One Solution collect form web for “git -submodules / repo – How to use commit and branch for a bunch of branches in separate modules?”

    Plain vanilla git answer (using submodules):

    This kind of process done for each submodule could be initiated with:

    git submodule foreach [--recursive] ...
    

    With ‘…’ referring to a git alias which would include all your commands.

    From git submodule man page:

    foreach
    

    Evaluates an arbitrary shell command in each checked out submodule.
    The command has access to the variables $name, $path, $sha1 and $toplevel:

    • $name is the name of the relevant submodule section in .gitmodules,
    • $path is the name of the submodule directory relative to the superproject,
    • $sha1 is the commit as recorded in the superproject, and
    • $toplevel is the absolute path to the top-level of the superproject.

    Any submodules defined in the superproject but not checked out are ignored by this command.
    Unless given --quiet, foreach prints the name of each submodule before evaluating the command.
    If --recursive is given, submodules are traversed recursively (i.e. the given shell command is evaluated in nested submodules as well).


    The issue is that the android repo wrapper command does what git submodule does in its own unique way.
    So an equivalent of git submodule foreach might be: repo forall, e.g.:

    repo forall -c 'git status'

    Git Baby is a git and github fan, let's start git clone.