Skip to content

Instantly share code, notes, and snippets.

@demonar
Last active August 22, 2023 15:57
Show Gist options
  • Save demonar/879ad213587c835f444ac38acc416e44 to your computer and use it in GitHub Desktop.
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
#!/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