Skip to content

Instantly share code, notes, and snippets.

@beekhof
Created February 21, 2011 10:05
Show Gist options
  • Save beekhof/836887 to your computer and use it in GitHub Desktop.
Save beekhof/836887 to your computer and use it in GitHub Desktop.
# Put this in ~/.gitconfig
# https://git.wiki.kernel.org/index.php/Aliases
[alias]
ci = commit
co = checkout
fp = format-patch
bl = blame --date=short -M
br = !git branch --no-color | grep '*' | sed -e 's/^* //'
who = shortlog -s --
top = !eval cd "$(pwd)/$(git rev-parse --show-cdup)" && pwd
annotate = blame
lg = log --pretty=format:'%an (%ar) %h: %s %C(bold blue)%d%Creset' --date=relative --abbrev-commit --graph -M
lg-all = log --pretty=format:'%an (%ar) %h: %s %C(bold blue)%d%Creset' --date=relative --abbrev-commit --graph -M --all
slg = log --pretty=format:'%an (%ar) %h: %s %C(bold blue)%d%Creset' --date=relative --abbrev-commit --graph -M
log-color = log --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit --date=relative --all
# Mercurial compatability
in = ! "echo Incoming commits from origin/master; git fetch ; git slg ..origin/master"
out = ! "echo Outgoing commits from branch: $(git br); git slg $(git br) --not --remotes=*/master"
br-in = ! "echo Incoming commits from origin/$(git br); git fetch ; git slg ..origin/$(git br)"
br-out = ! "echo Commits not yet uploaded to branch: $(git br); git slg $(git br) --not --remotes=*/$(git br)"
up = remote update
id = !git show --pretty="format:%h" | head -n 1
id-long = !git show --pretty="format:%H" | head -n 1
url = !giturl
amend = commit --amend -C HEAD
amend-log= commit --amend
unmerge = reset --merge ORIG_HEAD
discard = "!sh -c 'git diff $* | patch -p1 -R' -"
rollback = reset --mixed HEAD^
strip = "!sh -c '[ $# = 1 ] && git reset --hard $1 && exit 0 || echo \"usage: git strip <hash> $#\" >&2 && exit 1' -"
edit = "!sh -c '[ $# = 1 ] && git rebase -i $1^ && exit 0 || echo \"usage: git edit <hash> $#\" >&2 && exit 1' -"
import = apply
#or... = am --signoff --3way --interactive
s = "!git diff --name-status | sed -e 's/^/W /' ; git diff --cached --name-status | sed -e 's/^/C /'"
st = "!f() { git ls-files --exclude-standard -t -u -s -m -d $@ | sed -e 's/C.*\t/C /' ; } ; f"
sto = !git st -o
br-st = ! "git ds; git in; git br-in; git out; git br-out"
df = diff
ds = diff --stat -r
cds = !git ds --cached
changes = diff --name-status -r
save = stash save
restore = stash pop
post = send-email --suppress-cc=self --compose --confirm=compose [email protected]
# git graphviz --first-parent master | dotty /dev/stdin
graphviz = "!f() { echo 'digraph git {' ; git log --pretty='format: %h -> { %p }' \"$@\" | sed 's/[0-9a-f][0-9a-f]*/\"&\"/g' ; echo '}'; }; f"
# git alias new_alias original_command
alias = !sh -c '[ $# = 2 ] && git config --global alias.\"$1\" \"$2\" && exit 0 || echo \"usage: git alias <new alias> <original command>\" >&2 && exit 1' -
aliases = !git config --get-regexp 'alias.*' | colrm 1 6 | sed 's/[ ]/ = /'
debug = !GIT_PAGER= gdb --args git
# Weird but might make good references
#file-blame = !git ls-files | xargs -n1 -i{} git log -1 --pretty=format:\"%ci %an {}\" -- {}
#rclone = clone --reference /git/cache.git/
#edit-last-commit = !vim `git diff-tree -r --name-only HEAD HEAD~1`
#edit-unmerged = "!f() { git ls-files --unmerged | cut -f2 | sort -u ; }; vim `f`"
#add-unmerged = "!f() { git ls-files --unmerged | cut -f2 | sort -u ; }; git add `f`"
#prune-all = !git remote | xargs -n 1 git remote prune
#push-head = !git push origin `git symbolic-ref HEAD`
#publish = push publish
#pushall = !git remote | xargs -n1 git push
#pushalltags = !git remote | xargs -n1 git push --tags
#test = !sh -c 'echo cmd=$1 arg1=$2 arg2=$3'
#dirstatus = !ls -d1 */.git | xargs -n1 -i{} sh -c \"cd {}/.. && echo Checking {} && git ls-files --exclude-standard -tousmd\"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment