Skip to content

Instantly share code, notes, and snippets.

@mmassaki
Created March 14, 2014 22:26
Show Gist options
  • Select an option

  • Save mmassaki/9558284 to your computer and use it in GitHub Desktop.

Select an option

Save mmassaki/9558284 to your computer and use it in GitHub Desktop.
New pull request from command line
#!/bin/sh
# Author: Massaki
# based on http://www.devthought.com/code/create-a-github-pull-request-from-the-terminal/
usage () {
echo "usage:" $@
exit 127
}
die () {
echo $@
exit 128
}
if test $# -lt 2
then
usage "$0 <remote> <parent branch>"
fi
remote=$1
parent=$2
repo=`git remote -v | grep "$remote.*(push)" | sed -e "s/.*github.com[:/]\(.*\)\.git.*/\1/"`
if test ${#repo} -le 0
then
die "Remote repository \"$remote\" not found or invalid. Is it a Github repository?"
fi
branch=`git name-rev --name-only HEAD`
echo "Creating pull request for branch \"$branch\" to branch \"$parent\" in \"$repo\""
open https://github.com/$repo/pull/new/$parent...$branch
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment