Skip to content

Instantly share code, notes, and snippets.

@becsegal
Created January 3, 2013 21:52
Show Gist options
  • Select an option

  • Save becsegal/4447711 to your computer and use it in GitHub Desktop.

Select an option

Save becsegal/4447711 to your computer and use it in GitHub Desktop.
Compare your current git branch to another branch on github. Uses master as the default branch.
#! /bin/bash
# compare your current checked out git branch to another branch on github
# default branch is master
# usage:
# ./compare.sh
# ./compare.sh staging
old=$1
if [ -z $1 ]; then
echo "Comparing to master. If you want to compare to a different branch use:"
echo "./script/compare branch_name"
old='master'
fi
remote=$(git config --get remote.origin.url)
echo $remote
if [[ $remote =~ com:([0-9a-zA-Z-]+/[0-9a-zA-Z-]+)\.git ]]; then
path=${BASH_REMATCH[1]}
branch=$(git rev-parse --symbolic-full-name --abbrev-ref HEAD)
origin=$
open https://github.com/$path/compare/$old...$branch
else
echo "Couldn't determine your github url. Make sure remote.origin.url is set in your git config."
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment