Skip to content

Instantly share code, notes, and snippets.

@rishi1999
Last active August 13, 2020 04:53
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rishi1999/f0986fe1f63de586bc503dd25de8dc91 to your computer and use it in GitHub Desktop.
Save rishi1999/f0986fe1f63de586bc503dd25de8dc91 to your computer and use it in GitHub Desktop.
git log pretty printing

This command allows you to see your commit history in a much more aesthetically appealing format:

git log --pretty=format:'%Cred%h %C(bold green)(%ad)%Creset %<|(78,trunc)%s %C(bold blue)<%an>%C(bold yellow)%d%Creset%n%n%-b' --date=format:'%b %d, %I:%M%P' --graph

Run this command in your terminal to make git lg an alias for the above:

git config --global alias.lg "log --pretty=format:'%Cred%h %C(bold green)(%ad)%Creset %<|(78,trunc)%s %C(bold blue)<%an>%C(bold yellow)%d%Creset%n%n%-b' --date=format:'%b %d, %I:%M%P' --graph"

Inspired by this post by Filipe Kiss.

@rishi1999
Copy link
Author

rishi1999 commented Aug 12, 2020

Note: if it doesn't work, try replacing the date portion with --date=relative, --date=short, or one of the other options from the git log man page. It seems that the original configuration only works on more recent versions of git.

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