Last active
October 3, 2015 18:18
-
-
Save burtlo/2502531 to your computer and use it in GitHub Desktop.
Github pull request from the command-line
This file contains hidden or 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
function pull-request { | |
hub pull-request -h $(__github_remote_origin):$(__github_current_branch) | |
} | |
function __github_remote_origin { | |
# Finds the origin on github if it is https or git | |
echo "$1`git remote -v | grep -e "^origin.* (push)" | sed "s#origin[[:blank:]]https://github.com/\([^/]*\)\/.*#\1#" | sed "s#origin.*:\([^/]*\).*push.*#\1#"`" | |
} | |
function __github_current_branch { | |
echo "$1`git branch --no-color 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/\1/'`" | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
By default hub's pull requests will set up a pull-request from a repo you own
burtlo:xcoder
to the one you are working inrayh:xcoder
.This default behavior is problematic when you are working in a shared repo that is not your own or an organization repo. This little script let me send a pull request from say
rayh:my-branch
torayh:branch
when you have the rights to do it.