Skip to content

Instantly share code, notes, and snippets.

@PVince81
Created February 10, 2017 09:00
Show Gist options
  • Save PVince81/f58f6dfd6cf54c4a6ba9322187873180 to your computer and use it in GitHub Desktop.
Save PVince81/f58f6dfd6cf54c4a6ba9322187873180 to your computer and use it in GitHub Desktop.
Open the Github Pull Request page for the current branch with optional target branch
#!/bin/bash
# Inspired by http://www.devthought.com/code/create-a-github-pull-request-from-the-terminal/
targetbranch=master
if test "$1"; then
targetbranch=$1
fi
repo=`git remote -v | grep -m 1 "(push)" | sed -e "s/.*github.com[:/]\(.*\)\.git.*/\1/"`
branch=`git name-rev --name-only HEAD`
echo "Creating pull request for branch \"$branch\" in \"$repo\""
xdg-open "https://github.com/$repo/pull/new/$targetbranch...$branch"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment