Skip to content

Instantly share code, notes, and snippets.

@georgebrock
Created June 3, 2012 22:54
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save georgebrock/65f2e8e5c9f5c38a89fe to your computer and use it in GitHub Desktop.
Save georgebrock/65f2e8e5c9f5c38a89fe to your computer and use it in GitHub Desktop.
Git aliases & extensions
[alias]
graph = log --all --graph --decorate --oneline -n30
cb = !git branch | grep ^* | cut -d' ' -f2
rb = !git for-each-ref --format='%(upstream:short)' "refs/heads/$(git cb)"
sb = !ls .git/refs/remotes/*/$(git cb) | cut -d/ -f4,5 | \
xargs git show-branch $(git cb)
rgrep = !git grep
#!/bin/bash
github_remote=$(git remote -v | grep -Eo 'github.com[:/][^.]+' | head -1)
if [ -z $github_remote ]
then
echo "No GitHub remote"
exit
fi
github_url="https://${github_remote/://}/"
if [ ! -z $1 ]
then
sha=$(git rev-parse $1)
github_url="${github_url}commit/$sha"
fi
open $github_url
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment