Skip to content

Instantly share code, notes, and snippets.

@wallin
Last active December 12, 2015 09:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save wallin/4754087 to your computer and use it in GitHub Desktop.
Save wallin/4754087 to your computer and use it in GitHub Desktop.
Useful git aliases
[color]
diff = auto
status = auto
branch = auto
[alias]
b = branch
ba = branch -a
ci = commit
co = checkout
d = diff
d1 = diff HEAD~1
d2 = diff HEAD~2
d3 = diff HEAD~3
dc = diff --cached
fp = format-patch
g = !git gui &
gr = log --graph
go = log --graph --pretty=oneline --abbrev-commit
k = !gitk &
ka = !gitk --all &
lc = log ORIG_HEAD.. --stat --no-merges
lp = log --patch-with-stat
mnf = merge --no-ff
mnff = merge --no-ff
mt = mergetool
p = format-patch -1
serve = !git daemon --reuseaddr --verbose --base-path=. --export-all ./.git
sra = svn rebase --all
sh = !git-sh
st = status
stm = status --untracked=no
stfu = status --untracked=no
pullsrb = !git stash save && git pull --rebase && git stash pop && echo 'Success!'
r = !git l -30
ra = !git r --all
l = "!source ~/.githelpers && pretty_git_log"
la = !git l --all
pr = pull --rebase
ll = log --pretty=format:"%C(yellow)%h%Cred%d\\ %Creset%s%Cblue\\ [%cn]" --decorate --numstat
HASH="%C(yellow)%h%Creset"
RELATIVE_TIME="%Cgreen(%ar)%Creset"
AUTHOR="%C(bold blue)<%an>%Creset"
REFS="%C(red)%d%Creset"
SUBJECT="%s"
FORMAT="$HASH}$RELATIVE_TIME}$AUTHOR}$REFS $SUBJECT"
show_git_head() {
pretty_git_log -1
git show -p --pretty="tformat:"
}
pretty_git_log() {
git log --graph --pretty="tformat:${FORMAT}" $* |
# Replace (2 years ago) with (2 years)
sed -Ee 's/(^[^<]*) ago)/\1)/' |
# Replace (2 years, 5 months) with (2 years)
sed -Ee 's/(^[^<]*), [[:digit:]]+ .*months?)/\1)/' |
# Line columns up based on } delimiter
column -s '}' -t |
# Page only if we need to
less -FXRS
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment