Zyzle.dev

Git Aliases

18th February, 2023

Some useful git aliases:

  • hist gives a slightly prettier version of the standard log

  • graphviz creates a graphviz importable log

  • lg pretty console based logging

  • sweep remove local copies of branches that have already been merged to master or develop

[alias]
hist = log --oneline --decorate --graph
graphviz = "!f() { echo 'digraph git {' ; git log --pretty='format: %h -> { %p }' \"$@\" | sed 's/[0-9a-f][0-9a-f]*/\"&\"/g' ; echo '}'; }; f"
lg = log --graph --abbrev-commit --decorate --format=format:'%C(bold blue)%h%C(reset) - %C(bold green)(%ar)%C(reset) %C(white)%s%C(reset) %C(dim white)- %an%C(reset)%C(bold yellow)%d%C(reset)' --all
sweep = "!f() { git branch --merged | grep -Ev '(*|master|develop)' | xargs -n 1 git branch -d; }; f"