Skip to content

Instantly share code, notes, and snippets.

@johanmeiring
Created June 27, 2012 08:32
Show Gist options
  • Save johanmeiring/3002458 to your computer and use it in GitHub Desktop.
Save johanmeiring/3002458 to your computer and use it in GitHub Desktop.
"git lg" alias for pretty git log
# From http://garmoncheg.blogspot.com/2012/06/pretty-git-log.html
git config --global alias.lg "log --color --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit --"
@vibrantwebs
Copy link

Thank you!

@CarterPlus
Copy link

good

@stdedos
Copy link

stdedos commented Feb 24, 2022

You might also want to:

  • Remove "forced" --color (e.g. piping)
  • tformat instead of format (tl;dr: newline at the end of the command)
git config --global alias.lg "log --graph --pretty=tformat:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit --decorate=full"

@jakeinater
Copy link

You can also change -%C(yellow)%d%Creset to -%C(auto)%d%Creset if you want your branches to be different colors

@blacksmithop
Copy link

Thanks

@talktosalvador
Copy link

muchas gracias crack!

@FacundoEG
Copy link

un capo total

@annluky
Copy link

annluky commented Oct 31, 2023

nice, thank you

@ocramz
Copy link

ocramz commented May 10, 2024

You can also change -%C(yellow)%d%Creset to -%C(auto)%d%Creset if you want your branches to be different colors

for posterity:

git config --global alias.lg "log --graph --pretty=tformat:'%Cred%h%Creset -%C(auto)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit --decorate=full"

@grazianobolla
Copy link

gracias de nuevo capo

@ak1ra-komj
Copy link

Thanks for the snippets

I prefer to set up an alias in ~/.bashrc, so that I can simply execute the gl command directly,

alias gl="git log --abbrev-commit --graph --pretty=tformat:'%Cred%h%Creset -%C(auto)%d%Creset %s %Cgreen(%ci) %Cblue%an <%ae>%Creset'"

@manf50
Copy link

manf50 commented Jul 11, 2025

thanks a lot. Putting it as an alias in ~/.bashrc is even more elegant. Could do the same for "git push" or "git pull" maybe ...?

@taprile314
Copy link

tipazo

@Amatikay
Copy link

Спасибо

@marounmelhem
Copy link

I just wanna let you know that I've been using this for more than 10 years

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment