Created
March 23, 2012 01:34
-
-
Save gmassanek/2166057 to your computer and use it in GitHub Desktop.
Alias to push and open chrome to the new pull request page
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
function git_remote_url() { | |
# DOES NOT WORK FOR HTTPS, ONLY [email protected]:username/repo.git | |
git config --get remote.origin.url | sed 's/git@//' | sed 's/github/https:\/\/github/' | sed 's/com:/com\//' | sed 's/\.git//' | |
} | |
function git_current_branch_name() { | |
git symbolic-ref HEAD | sed 's/refs\/heads\///' | |
} | |
function git_push_open() { | |
branch_name=$1 | |
if [ -z $branch_name ]; then | |
branch_name=`git_current_branch_name` | |
fi | |
git_repo_url=`git_remote_url` | |
pull_path="/pull/new/" | |
$new_pull_request_url=$git_repo_url$pull_path$branch_name | |
echo $new_pull_request_url | |
git push origin HEAD:$branch_name && open $new_pull_request_url | |
} | |
alias gpush="git_push_open" |
This requires you to run git config host.url https://github.com/username/repo
function git_remote_url() {
# DOES NOT WORK FOR HTTPS, ONLY [email protected]:username/repo.git
git config --get remote.origin.url | sed 's/git@//' | sed 's/github/https:\/\/github/' | sed 's/com:/com\//' | sed 's/\.git//'
}
function configured_url() {
git config --get host.url
}
function git_current_branch_name() {
git symbolic-ref HEAD | sed 's/refs\/heads\///'
}
function git_push_open() {
branch_name=$1
if [ -z $branch_name ]; then
branch_name=`git_current_branch_name`
fi
git_repo_url=`configured_url`
if [ -z $branch_name ]; then
git_repo_url=`git_remote_url`
fi
pull_path="/pull/new/"
echo "Pushing HEAD to "$branch_name
echo "Click Open Pull Request on "$git_repo_url$pull_path$branch_name
git push origin HEAD:$branch_name && open $git_repo_url$pull_path$branch_name
}
alias gpush="git_push_open"
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Also one of my favorites.
alias gprom="git pull --rebase origin master"