I have a git repository that contains other git repositories. Are there commands that recursively push and/or pull for not only the meta-repository but the sub-repositories?
A git submodule is a record within a host git repository that points to a specific commit in another external repository. Submodules are very static and only track specific commits. Submodules do not track git refs or branches and are not automatically updated when the host repository is updated.
You can also change the commit that is checked out in each submodule by performing a checkout in the submodule repository and then committing the change in the parent repository. You add a submodule to a Git repository via the git submodule add command.
git submodule update --init --recursive --remote - updates all submodules recursively along their tracking branches. Without the --remote , it'll reset the submodule working directories to the "right" commit for the parent.
I find myself in the same situation whenever I want to update my llvm/clang repositories and with a bit of bash help I can 'git pull' each of them like this:
$> for dir in $(find . -name ".git"); do cd ${dir%/*}; git pull ; cd -; done
This will 'git pull' all git repos found under your current directory, and probably wont work if they are bare repositories.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With