/ git-open-in-github
git-open-in-github
1 #!/bin/sh 2 3 set -e # bail on errors 4 5 CURRENT_BRANCH=$(git rev-parse --abbrev-ref HEAD) 6 REMOTE="${1:-$(git config --get branch.${CURRENT_BRANCH}.remote)}" 7 BRANCH="${2:-$CURRENT_BRANCH}" 8 REPO=$(git config --get remote.${REMOTE}.url | cut -d':' -f2 | cut -d'.' -f1) 9 if [[ -z "$REPO" ]] || [[ -z "$BRANCH" ]]; then 10 echo "usage: $(basename "$0") <remote> <branch (ref)>" 11 exit 1 12 fi 13 open "https://github.com/${REPO}/compare/${BRANCH}?expand=1"