Created
November 1, 2012 14:31
-
-
Save brock/3993967 to your computer and use it in GitHub Desktop.
Open Github Diff comparing current branch to branch specified.
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
#!/bin/bash | |
# Save this file somewhere # ~/bin/ghd.sh | |
# Create an alias in .bashrc # alias ghd='bash ~/bin/ghd.sh' | |
# | |
# Usage: ghd <name_of_branch_on_github> | |
# Browser will open showing you the diff between current branch and the branch specified | |
DIFF_BRANCH=$1 | |
if [[ -z "$DIFF_BRANCH" ]]; then | |
echo "Please specifiy a branch to compare." | |
exit 1 | |
fi | |
GIT=$(which git) | |
BRANCH=$($GIT branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/\1/') | |
REMOTE=$($GIT remote -v | grep fetch | sed 's/\(.*github.com\)[:|/]\(.*\).git (fetch)/\2/') | |
open "https://github.com/$REMOTE/compare/$DIFF_BRANCH...$BRANCH" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment