-
-
Save isao/2883598 to your computer and use it in GitHub Desktop.
Easy GitHub pull requests
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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