Created
November 2, 2018 18:13
-
-
Save rakaramos/1c2069a3b1a4edcf46c653f8ec5e1dd2 to your computer and use it in GitHub Desktop.
Git command to push to the remote and open browser with 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-pr() { | |
git rev-parse --abbrev-ref --symbolic-full-name @{u} 2>/dev/null | |
if [[ $? > 0 ]]; then | |
# no upstream, lets add that | |
upstreamAdd="-u" | |
fi | |
branch=$(git symbolic-ref --short HEAD) | |
git push "${upstreamAdd}" origin "${branch}" 2>&1 | egrep -iEo "http(s)://?.+$" | xargs open | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Here's the
git alias
versionOne should add that to
~/.gitconfig
for global and.git/config
.P.S: I'm not sure why Github only returns the PR URL on branch creation. Gitlab, for example, always returns it.