loading...
Cover image for Nice looking Git log

Nice looking Git log

amaltapalov profile image Amal Tapalov ・1 min read

One of the most used git command is git log which shows commit logs.

$ git log

I found custom git lg looks more self-sufficient and descriptive. If you want to have this command follow next instruction.

Following image shows what's the difference between custom git lg and git log --oneline.

Instruction:

Go to C:\Users\YOURUSERNAME and add code in .gitconfig file:

[alias]
    lg = log --color --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit --branches

That's it!

From now on you can call git lg and have new view in terminal. Enjoy!

Discussion

pic
Editor guide
Collapse
exadra37 profile image
Paulo Renato

Cool tip.

I am on Linux, and I use the OhMyZsh shell that have already pretty print alias for git log, and for example the glg one looks like:

git-log

$ alias | grep glg -
glg='git log --stat'
glgg='git log --graph'
glgga='git log --graph --decorate --all'
glgm='git log --graph --max-count=10'
glgp='git log --stat -p'
Collapse
amaltapalov profile image
Amal Tapalov Author

I don't work on Linux but anyway it always good to know other solutions

Collapse
exadra37 profile image
Paulo Renato

The alias I have in Linux should work in Windows to, just give it a try... define them in the same way you have define the one in this article.

Collapse
chadalen profile image
Collapse
garetmckinley profile image
Garet McKinley

I personally prefer CLI for things like git. I've had too many bad experiences in the past with gui tools. I feel safer knowing exactly what commands I'm issuing

Collapse
amaltapalov profile image
Amal Tapalov Author

Agree with you. I had such cases too, for ex. Sourcetree sometimes didn't want to launch at all. It sucks.

Thread Thread
chadalen profile image
Chad Alen

Sourcetree is terrible don't use that. If you’re on Windows or Mac give Git Fork a try. I used Sourcetree before I loved how it looked and how simple it was but it was slow and buggy it actually made me switch to command line. I just don’t like typing out the commands all the time.

Thread Thread
amaltapalov profile image
Amal Tapalov Author

100% true about Sourcetree.

Thread Thread
mirolago profile image
mirolago

I love Sourcetree. It got better. For cherry picking very handy.

Thread Thread
jeklah profile image
Jeklah

Use cherry-picking with interactive flag.

Collapse
chadalen profile image
Chad Alen

There's a button on Git Fork that shows you what commands it's calling underneath.
image

Thread Thread
jeklah profile image
Jeklah

One of the reasons people prefer CLI over GUIs is the lack of difference between them. A cli is the same wherever, GUIs vary widely from usability to launching. Some have good features some have bad.

Also useful to know if you have to go on site and they don't have a GUI.

Skip to do what you want with CLI with a bit of practice. Git isn't too bad to learn on the CLI anyway.

Thread Thread
chadalen profile image
Chad Alen

I know CLI and I use it when the GUI doesn’t work. I just find typing the commands every time very tedious. I’d rather click to do what I want.

Collapse
develosaur profile image
Derek

Never heard of it before. Tried all the others like tower, kraken etc. and settled on sourcetree. Haven't had issues, but I will give fork a try.

Collapse
garetmckinley profile image
Garet McKinley

I swear every time I open DEV there's an article on the homepage that's relevant to what I'm looking for in the moment.

Super nice alias, thanks!

Collapse
amaltapalov profile image
Amal Tapalov Author

Good to know that you found what you was looking for. Welcome!

Collapse
jeklah profile image
Jeklah

Nice, thanks. I did have a glg alias for this same log but I lost it in a recent resetup after my cygwin setup died on me.
Now I'm switching to WSL.
I spent a good amount of last night/early this morning trying to get a log view I was happy with. The best I could get was git log --graph --pretty --oneline but it lacks the author, date (relative) and tags. Yours looks like it has all but tags, but I think I saw that option last night while tab-exploring options ..
But would you mind explaining the black magic that is the pretty formatting syntax? I understand some of it...

Collapse
hungnguyenkt profile image
Hung Nguyen Manh

Thanks for sharing <3

Collapse
jonasws profile image
Jonas Strømsodd

If you're into colorful tools (and who's not, right?), I recommend having a look at tig. 🚀

Collapse
amaltapalov profile image
Amal Tapalov Author

Will have a look!