Skip to content

Instantly share code, notes, and snippets.

@carymrobbins
Last active December 22, 2015 05:39
Show Gist options
  • Save carymrobbins/6425431 to your computer and use it in GitHub Desktop.
Save carymrobbins/6425431 to your computer and use it in GitHub Desktop.
Adds the git pull-each feature to easily pull multiple branches.
#!/bin/bash
# Adds the git pull-each feature to easily pull multiple branches.
# Place this in a directory on your path (e.g. ~/bin).
set -e
ORIG_BRANCH=$(git branch | grep '*' | cut -c3-)
if [ -z "$1" ]; then
echo "usage: git pull-each [--all|branch1 [branch2 [...]]]"
exit
else
if [ "$1" == "--all" ]; then
BRANCHES=$(git branch | cut -c3-)
else
BRANCHES=$*
fi
fi
for BRANCH in $BRANCHES
do
git checkout $BRANCH
git pull
done
git checkout $ORIG_BRANCH
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment