Skip to content

Instantly share code, notes, and snippets.

Created Feb 26, 2012
What would you like to do?
Open Git Project in Github
# GH
# by Brock Angelo
# for Mac OSX & Unix
# Description: when you are on the command line and want to open your project in Github, just type "gh". Latest version opens the current branch on github as well.
# 1. Copy this snippet to ~/bin/gh
# 2. Make it executable by running: chmod +x ~/bin/gh
# 3. From the command line, inside your project, type gh and the browser window will open.
BRANCH=$(git branch | grep "*" | awk '{print $2}')
git remote -v | grep fetch | sed 's/\(.*\)[:|/]\(.*\).git (fetch)/\2/' | awk -v BRANCH=$BRANCH {'print "" $1 "/tree/" BRANCH'} | xargs open
Copy link

brock commented Feb 28, 2012

updated to work for projects you don't own

Copy link

brock commented Mar 28, 2012

updated to check locally rather than querying remotely - saves about a second or two.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment