Zyzle.dev
;

Useful git aliases

18th February, 2023

Some git aliases I find useful and add to most of my development environments:

  • 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
.gitconfig
[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"