Skip to content

Instantly share code, notes, and snippets.

@mythmon
Created March 19, 2013 17:58
Show Gist options
  • Save mythmon/5198494 to your computer and use it in GitHub Desktop.
Save mythmon/5198494 to your computer and use it in GitHub Desktop.
#!/bin/bash
function remote_by_name() {
name=$1
remote_line=$(git remote -v | grep push | grep $name)
if [[ -z $remote_line ]]; then
echo "Error: remote '$name' not found."
exit 1
fi
if [[ ! $(echo $remote_line | grep github) ]]; then
echo "Error: $name is not on github!"
exit 1
fi
repo=$(echo $remote_line |
sed 's/.*github.com[:\/]\([^ ]*\) .*/\1/' |
sed 's/\.git//')
echo $repo
}
origin=$(remote_by_name origin)
branch=$(git branch | grep '^*' | awk '{print $2}')
git push origin $branch:$branch
xdg-open "https://github.com/$origin/pull/new/$branch" > /dev/null
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment