Created
December 18, 2014 10:27
-
-
Save dasch/c43438c56f45ac7b23a5 to your computer and use it in GitHub Desktop.
Open the GitHub compare page for a branch
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
#!/bin/bash | |
local_branch=$(git for-each-ref --format="%(refname:short)" $(git symbolic-ref HEAD)) | |
remote_name=$(git config branch.$local_branch.remote) | |
remote_refspec=$(git config branch.$local_branch.merge) | |
remote_branch=${remote_refspec#refs/heads/} | |
remote_git_url=$(git config remote.origin.url) | |
remote_http_url=${remote_git_url#[email protected]:} | |
remote_http_url=${remote_http_url%.git} | |
github_url="https://github.com/$remote_http_url" | |
compare_url="$github_url/compare/$remote_branch" | |
open $compare_url |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment