Last active
August 22, 2023 15:57
-
-
Save demonar/879ad213587c835f444ac38acc416e44 to your computer and use it in GitHub Desktop.
This script updates all the branches, like running pull on every local branch
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 | |
cd $1 | |
declare -a BRANCHES=(`git for-each-ref --format='%(refname:short)' refs/heads/`) | |
CURRENT=(`git rev-parse --abbrev-ref HEAD`) | |
for BRANCH in "${BRANCHES[@]}" | |
do | |
if [ "$CURRENT" = "$BRANCH" ] | |
then | |
git pull | |
else | |
git fetch origin "$BRANCH":"$BRANCH" | |
fi | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment