Skip to content

Instantly share code, notes, and snippets.

@johanmeiring
Created June 27, 2012 08:32
Show Gist options
  • Select an option

  • Save johanmeiring/3002458 to your computer and use it in GitHub Desktop.

Select an option

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 --"
@Sleavely
Copy link
Copy Markdown

Tip: Remove the last -- to be able to set flags when using the alias.

For example, to view all branches (regardless of whether they are merged into the current one) you could then do git lg --all. This works for any flags that work with the original git log command.

@taprile314
Copy link
Copy Markdown

gracias bro

@grazianobolla
Copy link
Copy Markdown

que bien

@AngelRausseo
Copy link
Copy Markdown

nice men

@leodelgadodev
Copy link
Copy Markdown

graciela mostro

@vibrantwebs
Copy link
Copy Markdown

Thank you!

@CarterPlus
Copy link
Copy Markdown

good

@stdedos
Copy link
Copy Markdown

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
Copy Markdown

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
Copy Markdown

Thanks

@talktosalvador
Copy link
Copy Markdown

muchas gracias crack!

@FacundoEG
Copy link
Copy Markdown

un capo total

@annluky
Copy link
Copy Markdown

annluky commented Oct 31, 2023

nice, thank you

@ocramz
Copy link
Copy Markdown

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
Copy Markdown

gracias de nuevo capo

@ak1ra-komj
Copy link
Copy Markdown

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
Copy Markdown

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
Copy Markdown

tipazo

@Amatikay
Copy link
Copy Markdown

Бпасибо

@marounmelhem
Copy link
Copy Markdown

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

@imom0
Copy link
Copy Markdown

imom0 commented Oct 28, 2025

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

metoo

@The1nk
Copy link
Copy Markdown

The1nk commented Mar 23, 2026

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

metoo

same

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

same

love this thing - just came back to find it .. again .. πŸ˜†

@stdedos
Copy link
Copy Markdown

stdedos commented Mar 24, 2026

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

metoo

same

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

same

love this thing - just came back to find it .. again .. πŸ˜†

I just wanna let y'all know how annoying your "metoo" messages are ❀️

@marounmelhem
Copy link
Copy Markdown

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

metoo

same

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

same
love this thing - just came back to find it .. again .. πŸ˜†

I just wanna let y'all know how annoying your "metoo" messages are ❀️

you must be fun at parties

@The1nk
Copy link
Copy Markdown

The1nk commented Mar 25, 2026

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

metoo

same

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

same
love this thing - just came back to find it .. again .. πŸ˜†

I just wanna let y'all know how annoying your "metoo" messages are ❀️

fyi

image

@stdedos
Copy link
Copy Markdown

stdedos commented Mar 25, 2026

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

metoo

same

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

same
love this thing - just came back to find it .. again .. πŸ˜†

I just wanna let y'all know how annoying your "metoo" messages are ❀️

fyi

image

Oh thanks! I probably didn't want to "keep up with real updates", and instead I wanted to keep up with the metoos ☺️

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