Last active
December 22, 2015 05:39
-
-
Save carymrobbins/6425431 to your computer and use it in GitHub Desktop.
Adds the git pull-each feature to easily pull multiple branches.
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 | |
# 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