Skip to content

Instantly share code, notes, and snippets.

@samsonjs
Created April 11, 2010 23:38
Show Gist options
  • Save samsonjs/363139 to your computer and use it in GitHub Desktop.
Save samsonjs/363139 to your computer and use it in GitHub Desktop.
#!/usr/bin/env zsh
git-pull-all-branches() {
if ! git rev-parse --is-inside-work-tree >/dev/null 2>&1; then
echo "$pwd is not part of a git repo"
return
fi
origbranch=$(git branch | fgrep '*' | sed -e 's/\* //')
bs=($@)
[[ -z "$bs" ]] && bs=($(git branch | sed -e 's/\* //'))
for b ($bs) {
git checkout $b
git pull origin $b
}
git checkout $origbranch
}
alias pab='git-pull-all-branches'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment