Last active
July 24, 2020 07:34
-
-
Save siredmar/d07987d92c1242da36b448f4ea082b26 to your computer and use it in GitHub Desktop.
Script that fetches and pulls all remote branches of a bunch of git repositories
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
#usage: ./fetchall.sh <dir-containing-several-git-repos> | |
input=$1 | |
for git in $(find $input -maxdepth 1 -mindepth 1 -type d -printf '%f\n') | |
do | |
git -C $input/$git branch -r | grep -v '\->' | while read remote; do git -C $input/$git branch --track "${remote#origin/}" "$remote"; done | |
git -C $input/$git fetch --all | |
git -C $input/$git pull --all | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment