Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Recursive Git push/pull?

Tags:

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?

like image 899
David Y. Stephenson Avatar asked Jul 10 '13 13:07

David Y. Stephenson


People also ask

How submodules work in git?

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.

Can you commit from a submodule?

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.

What is git submodule update -- init -- recursive?

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.


1 Answers

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.

like image 108
vguerra Avatar answered Oct 16 '22 04:10

vguerra