Skip to content

Instantly share code, notes, and snippets.

@htchaan
Created November 4, 2015 05:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save htchaan/64f8af7f39e99c64639b to your computer and use it in GitHub Desktop.
Save htchaan/64f8af7f39e99c64639b to your computer and use it in GitHub Desktop.
Git checkout all remote branches
#!/bin/bash
function gcoa() {(
UPSTREAM=${1:=origin}
IFS=$'\n'
for BRANCH in $(git branch -r); do
BRANCH=${BRANCH# }
[[ "$BRANCH" != $UPSTREAM* ]] && continue
BRANCH=${BRANCH#$UPSTREAM/}
[ "${BRANCH:0:4}" = 'HEAD' ] && continue
git branch --track $BRANCH $UPSTREAM/$BRANCH
done
)}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment