If you're like me, you have some (or most) of your github repositories stored in some parent folder like ~/gitrepos
. Sometimes you want to just update multiple repositories together without having to git pull
each one individually. Hopefully this will help you.
First off, SSH access is required for private repos, so we'll assume you have this set up already. Github has enough documentation to cover this.
If your keys are password locked (as they should be), you should run
ssh-add
eval ($ssh-agent)
ssh-add
and then type your password to unlock the ssh for some time without having to keep prompting you.
Then you can just create a script like this while inside the ~/gitrepos
folder and run it.
declare -a dirs=(
"repo1"
"repo2"
"repo3")
for i in "${dirs[@]}"
do
echo "$i"
cd $i
git pull
git submodule update --remote
cd ..
done
I have added the submodule update line in case your repos have submodules which need to be updated.