Skip to content

Instantly share code, notes, and snippets.

@isao
Forked from CyberShadow/git-pullrequest.sh
Created June 6, 2012 17:57
Show Gist options
  • Save isao/2883598 to your computer and use it in GitHub Desktop.
Save isao/2883598 to your computer and use it in GitHub Desktop.
Easy GitHub pull requests
#!/bin/bash -e
# based on Vladimir Panteleev's https://gist.github.com/1885859
die() {
echo "$@" >&2
exit 1
}
branch=$(git name-rev --name-only HEAD 2>/dev/null)
ghusr=$(git config --get github.user)
ghrem=${1:-$(git remote -v | grep -Fm1 $ghusr/ | cut -f 1)}
ghuri=$(git remote -v | grep -m1 github.com: | egrep -o "$ghusr/\w+")
[[ -n $branch ]] || die 'no branch!'
[[ $branch != master && $branch != develop ]] || die 'use topic branch'
[[ -n $ghusr ]] || die "github.user not set"
[[ -n $ghrem ]] || die "no remote found for github.user '$ghusr'"
# push
git push -v $ghrem $branch
# run this script again to push again, or uncomment git config below to
# enable this behavior:
# % git push -v
# Pushing to git@github.com:isao/mojito.git
# To git@github.com:isao/mojito.git
# = [up to date] develop -> develop
# = [up to date] master -> master
# = [up to date] mu-ie-splice-bug -> mu-ie-splice-bug
# updating local tracking ref 'refs/remotes/myfork/develop'
# updating local tracking ref 'refs/remotes/myfork/master'
# updating local tracking ref 'refs/remotes/myfork/mu-ie-splice-bug'
# Everything up-to-date
#
#git config branch.$branch.remote $ghrem
# in your browser
open https://github.com/$ghuri/pull/new/$branch
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment