Last active
May 12, 2023 16:29
-
-
Save eusonlito/d5a3c0168e6e6988729c5eafbf0e44ab to your computer and use it in GitHub Desktop.
Update all git branches from remote on all 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 | |
HERE=$(pwd) | |
for env in api web; do | |
echo -e "\nUpdating $env\n" | |
cd $HERE/$env | |
CURRENT=$(git rev-parse --abbrev-ref HEAD) | |
git fetch --all > /dev/null | |
git remote prune origin > /dev/null | |
for branch in $(git branch -r | grep -v '\->' | sed 's/origin\///'); do | |
git checkout $branch > /dev/null | |
git pull origin $branch > /dev/null | |
echo "" | |
done | |
git checkout $CURRENT > /dev/null | |
done | |
echo "" | |
exit 0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment