Skip to content

Instantly share code, notes, and snippets.

@jbarnoud
Last active March 16, 2017 17:12
Show Gist options
  • Save jbarnoud/22b41564214b38dbb76997dd210ae482 to your computer and use it in GitHub Desktop.
Save jbarnoud/22b41564214b38dbb76997dd210ae482 to your computer and use it in GitHub Desktop.
A bash function that allows you to quickly checkout a branch for a pull request on a repo.
# Checkout a branch for a pull request
# Inspired from
# https://gist.github.com/captainsafia/954351fc7b05bb748b5d2112624f8a2f
function gh-pull {
if [[ "$#" != 2 ]]
then
echo "Arguments must be <remote> <PR-ID>."
return 1
fi
remote=$1
pr_id=$2
git fetch $remote pull/${pr_id}/head:pr-${pr_id}
git checkout pr-${pr_id}
}
jon@gerard:~/dev/mdanalysis$ gh-pull upstream 1215
remote: Counting objects: 10, done.
remote: Total 10 (delta 8), reused 8 (delta 8), pack-reused 2
Unpacking objects: 100% (10/10), done.
From github.com:MDAnalysis/mdanalysis
* [new ref] refs/pull/1215/head -> pr-1215
Switched to branch 'pr-1215'
@jbarnoud
Copy link
Author

More than inspired from captainsafia/gh-pull.fish.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment