Skip to content

Instantly share code, notes, and snippets.

@burtlo
Last active October 3, 2015 18:18
Show Gist options
  • Save burtlo/2502531 to your computer and use it in GitHub Desktop.
Save burtlo/2502531 to your computer and use it in GitHub Desktop.
Github pull request from the command-line
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/'`"
}
@burtlo
Copy link
Author

burtlo commented Apr 27, 2012

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 in rayh: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 to rayh:branch when you have the rights to do it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment