The git remote update
command will perform a fetch
operation on all remotes for a given repository:
$ git remote
larsks
origin
$ git remote update
Fetching origin
remote: Reusing existing pack: 1, done.
remote: Total 1 (delta 0), reused 0 (delta 0)
Unpacking objects: 100% (1/1), done.
From https://github.com/teythoon/afew
7317eb0..50db012 master -> origin/master
Fetching larsks
From github.com:larsks/afew
If you wanted to automatically run this across a collection of git
repositories, you could do something like this:
$ find * -maxdepth 1 -name .git -execdir git remote update \;
This finds everything containing a .git
directory and then runs git remote update
in the parent of the .git
directory.
To find all bare repositories, you could do something like:
$ find * -maxdepth 1 -name index -execdir git remote update \;
That is, look for the index
file instead of the .git
directory.
If you wanted to target all submodules, you can use the git submodule foreach
command:
$ find * -maxdepth 1 -name .git -execdir \
git submodule foreach git remote update \;
If you wanted to combine this all into a single command:
$ find * -maxdepth 1 -name .git -execdir \
sh -c 'git remote update; git submodule foreach git remote update' \;