euwpig
274.8K
· June 2012 ·
1900150 10203074354438338 1015529188 n

A better git log

So, are you tired of this old and bored git log screen?

Picture

How about this one, instead?

Picture

It's simple. Just type in:

git log --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit

I guess that's a bit too long, eh? Let's just make an alias. Copy and paste the line below on your terminal:

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"

And every time you need to see your log, just type in

git lg

Or, if you want to see the lines that changed

git lg -p

Picture

Hope you like it :)

PS: It seems that there's no way to view larger images, so I've linked bigger versions of them on the tip. Just click the image. Thanks to @basus(http://www.twitter.com/basus) for the note

Update: As some people were reporting, the git lg -p command wasn't working. As pointed out by the user universal_property at reddit, removing the -- at the end made it work.

Sign in or sign up to add your response.

43 Responses

720

This doesn't work for individual files

over 1 year ago ·
2306
1900150 10203074354438338 1015529188 n

@askjuise Thank. I've fixed. :)

over 1 year ago ·
3248

You guys can try this one :

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

this will:
-one commit per line

-show graph of commits

-abbreviated commit IDs

-dates relative to now

-show commit references (like git log --decorate)

-lots of colour

-show author of the commit

over 1 year ago ·
3634
Sergi2

Cool Filipe! Thanks!

over 1 year ago ·
4707

Great Filipe! Thanks :)

over 1 year ago ·
4862
920e3a8a79d806b3b165c4b20c5836c7

Very nice, thanks man

over 1 year ago ·
4865

thats amazing. thanks!

over 1 year ago ·
5114
61e84e983b8f1531a755a86b7d46cf43

Thanks man! For copy-pasting change-logs, here's an ascii friendly version:

git log --graph --pretty=format:'%h -%d %s (%cr) <%an>' --abbrev-commit

...and the alias:

git config --global alias.lg-ascii "log --graph --pretty=format:'%h -%d %s (%cr) <%an>' --abbrev-commit"
over 1 year ago ·
6976

[alias]
lg = !tig

google "tig" for more info

over 1 year ago ·
6981
0ada7b97d85873855231744286452af4

This is great, thanks!

Rather than a git alias, I opted for a bash alias by adding this line to my .bash_profile:
alias gitlog="git log --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit"

Now I have gitlog and gitlog -p.
Thanks again!

over 1 year ago ·
6987
7fb5a36640b1af1de3ac788c888f55fe
over 1 year ago ·
6988

Try this
git log --oneline --abbrev-commit --all --graph --decorate --color

It will give you one line commits, plus branching.

over 1 year ago ·
6990
8fdcf3909e4bcd4a027e7840b56a32a4

FYI, %h is for abbreviated commit hash, making --abbrev-commit redundant.

over 1 year ago ·
6993
Kevin suttle

Call me old fashioned. I use the alias glo mapped to

git log --decorate --oneline --graph and that works well for me.

Or, if I'm feeling like I need something a bit different, glg , which is mapped to

git log --decorate --graph --abbrev-commit --date=relative

https://github.com/kevinSuttle/dotfiles/blob/master/git/aliases.zsh#L11

over 1 year ago ·
6997
17f37be7dfd491b7b442a79f69e08f16

This is great! Thanks :D

over 1 year ago ·
7001

I like this one, that shows the branch graph on the left:

history = log --graph --pretty=format:'%C(yellow)%h%C(cyan)%d%Creset %s %C(white)- %an, %ar%Creset'
stash-list = stash list --pretty=format:'%Cblue%gd%Cred: %C(yellow)%s'q

Looks like: https://www.evernote.com/shard/s3/sh/1b468c02-8e39-499f-afd8-2fd3a099896c/88b8c39a380bc90b5809b2e9f4f069cc/deep/0/Screenshot%206/7/13%202:56%20PM.png

over 1 year ago ·
7003
1900150 10203074354438338 1015529188 n

@dshafik Mine also shows the graph :) It just happened to be a flat-line for the screenshots I've chose :P

over 1 year ago ·
7005
1277415d415a13a891f8c171893b2635

Love it!

over 1 year ago ·
7012
4f4c10a585c476957ab989299ec4dcb9

scm_breeze on github does something similar automatically plus a bunch of other nice aliases

over 1 year ago ·
8274
B7b49831b9a1e3f260d412488bbda9f8

Neat and simple...:)

over 1 year ago ·
8299
2f50851fd3c488bb2233b2727a6c8aa2

There is no need for --abbrev-commit.

Thanks for the tip though, I trimmed mine down to:

git log --format='%Cred%h%Creset %s %Cgreen(%cr) %C(blue)<%an>%Creset%C(yellow)%d%Creset' --no-merges
over 1 year ago ·
10653

This is great, thanks for sharing !

over 1 year ago ·
10876
E633424f80ce24effe8a115ec92a00ff

Great stuff.

over 1 year ago ·
11175
1ff5786158c0be54051ef8e5c544555d

I keep it simple with
git log --oneline --decorate --graph

This shows each commit on one line, decorates each line with any information about branches and repos and displays a graph where commits have branched or merged.

If you want to really personalise you git log with specific colours, here is an article to explain the syntax of all that in detail:
http://blog.jr0cket.co.uk/2013/06/designing-your-own-commit-graph-with-git.html

Thanks
John

over 1 year ago ·
11353
Df4b21be380e46f19da464a4dca2fdc1

In my gists NOW!

over 1 year ago ·
12020
2014 06 28 chopada med pesqueiro squared

Eu te amo! haha

over 1 year ago ·
12745
615c78618a762dc2574fd2324f6fe7c6

I'd prefer to set the default to --graph --decorate, rather than cook up a new alias. :/

over 1 year ago ·
12887
9c9aa9f7e8ba18dac52f3cb4703ffb9e

Nice! Any tips on porting this to Fish? I'm quite new to the command line stuff, and I can't find any reference to %C, string interpolation or command line styling for Fish shell. /lost

update: Okay, so the reason why I was getting an error was, I was putting white space between the '='. My bad! Carry along.

over 1 year ago ·
13314
78abc33e04b5d3645fb006ffd1679248

https://github.com/FredrikNoren/ungit

is kinda awesome

npm install -g ungit && ungit

if only I could post an image... oops

over 1 year ago ·
13969
Twitter picture normal

The git plugin of oh-my-zsh comes with tons of aliases, including log aliases.

  • alias glgg='git log --graph --max-count=10'
  • alias glgga='git log --graph --decorate --all'
  • alias glo='git log --oneline --decorate --color'
  • alias glog='git log --oneline --decorate --color --graph'
over 1 year ago ·
15432

Just install tig, a much much better command line tool for git

over 1 year ago ·
15489
F94a30ca59089778625ad8d8cff4c9aa

Pretty sweet!, now I can read the git log so much easier

over 1 year ago ·
15789
8c29cd63479505949897dffa767f49eb

As of Git 1.8.3 (May 24, 2013), you can now have (automatic) more comprehensive and useful colors on commits, branches and tags using %C(auto):

git log --graph --pretty=format:'%C(auto)%h -%d %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit
over 1 year ago ·
15790
8c29cd63479505949897dffa767f49eb

As of Git 1.8.3 (May 24, 2013), you can now have (automatic) more comprehensive and useful colors on commits, branches and tags using %C(auto):

git log --graph --pretty=format:'%C(auto)%h -%d %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit
over 1 year ago ·
15791
8c29cd63479505949897dffa767f49eb

As of Git 1.8.3 (May 24, 2013), you can now have (automatic) more comprehensive and useful colors on commits, branches and tags using %C(auto):

git log --graph --pretty=format:'%C(auto)%h -%d %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit
over 1 year ago ·
16253
8bb287773f4d761a1b5978acb493789b

Cool ;)
Take it.
Thank you Filipe.

over 1 year ago ·
16295
D3f29882f7d930928cd2cd4d9520fa50

awesome, Boy!

over 1 year ago ·
16793
Ae6f57d723e2c42784bce116e45218cb

Wow, cool. I guess I'll look at my log now than on Bitbucket or Github. Thanks for sharing.

over 1 year ago ·
16805
David

great. thanks for sharing

over 1 year ago ·
17914
Screen shot 2014 11 20 at 9.32.15 pm

nice!

over 1 year ago ·
18827
Dsc 1469

Great..!! thank you for sharing..

over 1 year ago ·
27471
8bitdikiaap

git log --color --graph --pretty=format:'%C(auto)%h%Creset ยป %d%s %Cgreen(%cr) %C(bold magenta)<%an>%Creset' --abbrev-commit Best for me.

30 days ago ·
27522

Thanks, i'll try it

14 days ago ·