Skip to content

Instantly share code, notes, and snippets.

@georgebrock
Created Jun 3, 2012
Embed
What would you like to do?
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