Skip to content

Instantly share code, notes, and snippets.

@gonzaloserrano
Created October 1, 2013 10:08
Show Gist options
  • Save gonzaloserrano/6776326 to your computer and use it in GitHub Desktop.
Save gonzaloserrano/6776326 to your computer and use it in GitHub Desktop.
Open current git directory in github (branch compatible)
# /bin/bash
# Opens the github page for the current git repository in your browser
# https://github.com/jasonneylon/dotfiles/
giturl=$(git config --get remote.origin.url)
if [ "$giturl" == "" ]
then
echo "Not a git repository or no remote.origin.url set"
exit 1;
fi
giturl=${giturl/git\@github\.com\:/https://github.com/}
giturl=${giturl/\.git//}
branch="$(git symbolic-ref HEAD 2>/dev/null)" || branch="(unnamed branch)" # detached HEAD
branch=${branch##refs/heads/}
giturl=${giturl}tree/$branch
open $giturl
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment