Skip to content

Instantly share code, notes, and snippets.

@avgerin0s
Created May 6, 2015 07:46
Show Gist options
  • Save avgerin0s/54a651676ad63394734f to your computer and use it in GitHub Desktop.
Save avgerin0s/54a651676ad63394734f to your computer and use it in GitHub Desktop.
Search remote branches and checkout to them using `pick`
#!/bin/sh
branch=$1
if [ -z $2 ]; then
remote=origin
else
remote=$2
fi
`git branch --remote | grep $branch | grep -v HEAD | sed "s/$remote\///" | pick | xargs git checkout`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment