DEV Community

Cover image for I love git log

I love git log

Andrew Stuntz on August 20, 2018

The title of this post should be IFLG (like IFLS, but ya know with Git). But it's probably not great to title a post with the f*** word....
Collapse
 
dmfay profile image
Dian Fay

I forget where I found this:

alias gtree='git log --graph --abbrev-commit --decorate --date=relative --format=format:'\''%C(bold blue)%h%C(reset) - %C(bold green)(%ar)%C(reset) %C(white)%s%C(reset) %C(dim white)- %an%C(reset)%C(bold yellow)%d%C(reset)'\'' --all'

Then gtree in your repo.

Collapse
 
vguarnaccia profile image
Vincent Guarnaccia

I'm totally going to borrow this. I add a '%G?' to my format so it's easy to see which commits are signed or not.

Collapse
 
sunbingfeng profile image
sunbingfeng

Yeah, you could add git alias to long command.

Collapse
 
latentfuss profile image
John Thompson

OoOoOo me Gusta!

Collapse
 
aurelkurtula profile image
aurel kurtula

This is great, thanks for sharing.

Collapse
 
hoelzro profile image
Rob Hoelz

I'm with you, Andrew - I think git log is my favorite part about Git!

I personally love using git log -S $QUERY to find out "hey, when did $QUERY appear in/disappear from the repository?" I was trying to figure out some things about what was removed between GTK 2 and 3, and -S is perfect for finding things like that!

Another log feature I love answers the question "I know I made this commit recently, and it contains the substring 'hello' - but which branch was it on?" For that I use git log --author=hoelz -G hello --all --source, which will print commits I wrote whose diff contains "hello". It searches across all branches, and prints the branch it used to find each commit.

Collapse
 
tux0r profile image
tux0r • Edited

Overall, it's pretty easy to see the ordering of the commits, top to bottom, first commit to last commit.

Which VCS does not do that?

What are your favorite parts of git?

To be honest, I have none. Everything Git provides is done in a similar or nearly identical way with Mercurial, the one thing both don't do too well, namely: merging incompatible branches, is the unique selling point for Darcs/Pijul.

Whenever I need to use Git, I surely prefer GitKraken. -- Alright, there is one thing Git does very well: The ecosystem of GUIs is very mature, even better than SVN's. :-)

Collapse
 
hoelzro profile image
Rob Hoelz

tux0r - have you written any posts on Pijul or Darcs? If not, you totally should! I think it would be really interesting to see a fresh perspective on what else is out there in the VCS world, and it would be a nice chance to highlight what non-Git source control systems bring to the table. I know a lot of people feel like Git has "won", but I myself have a soft spot for Mercurial, and I think having competition is essential to innovation in the space!

Collapse
 
tux0r profile image
tux0r

I find it sad to see that Atlassian does not advertise their own support for Mercurial. All you can find in their ads is Git here, Git there...

I haven't worked with Pijul yet. I made an account in their "nest" a while ago, but it's all too alpha-quality just yet. I have some private code on Darcshub though. No, I have not written anything about Darcs (yet?), Haskell is not my usual habitat. But I recommend everyone to spend half an hour with it. If you're not sold after that, you never will.

Thread Thread
 
slavius profile image
Slavius • Edited

I find it sad to see that Atlassian does not advertise their own support for Mercurial.

Nah, Atlassian does only what makes sales go high. Got a serious bug in Atlassian product? Wait few years until we finish new shiny graphical UI first!

Collapse
 
drews256 profile image
Andrew Stuntz

Which VCS does not do that?

Just trying to start out on the right foot.

the one thing both don't to too well, namely: merging incompatible branches, is the unique selling point for Darcs/Pijul.

I haven't used Darcs/Pijul before. But, I plan on writing somethings about merging/rebasing difficult branches. Which, probably isn't too different than what most people do, but there are ways to make merging less painful.

Whenever I need to use Git, I surely prefer GitKraken.

Yeah, I have used GitKraken, its the closest thing to a usable git GUI that I would use.

Collapse
 
eljayadobe profile image
Eljay-Adobe

I was disappointed with SourceTree.

I like Cycligent.

I thought GitKraken had the prettiest UI of the front-ends I've seen.

The only two problems I experienced with GitKraken, which is from a year or two ago:

  • abysmally slow (hopefully fixed by now...)
  • no Git LFS support (hopefully fixed by now...)
Thread Thread
 
tux0r profile image
tux0r

It is still slow because it still uses Electron AFAIK.

Collapse
 
ozzyogkush profile image
Derek Rosenzweig

Sourcetree is pretty good, though they have some annoying bugs once in a while.

Collapse
 
porky11 profile image
Fabio Krapohl

No, Git and Mercurial are very different.
In Git, branches are just a point in a history, similar to tags, just with regular updates.
In Mercurial, every commit belongs to a specific branch and it matters, which branch you merge into which one.

Besides that, Git has many GUIs, but none is good.
They often are incomplete, difficult to use and do a lot of unintended stuff in the background.
Mercurial has TortoiseHG, which just works like the command line stuff, and you can use many advanced command line features in GUI as well.

Collapse
 
joelnet profile image
JavaScript Joel

I have found these git aliases to be helpful. Paste this into your ~/.gitconfig file.

[alias]
    lg = !"git lg1"
    lg1 = !"git lg1-specific --all"
    lg2 = !"git lg2-specific --all"
    lg3 = !"git lg3-specific --all"

    lg1-specific = log --graph --abbrev-commit --decorate --format=format:'%C(bold blue)%h%C(reset) - %C(bold green)(%ar)%C(reset) %C(white)%s%C(reset) %C(dim white)- %an%C(reset)%C(auto)%d%C(reset)'
    lg2-specific = log --graph --abbrev-commit --decorate --format=format:'%C(bold blue)%h%C(reset) - %C(bold cyan)%aD%C(reset) %C(bold green)(%ar)%C(reset)%C(auto)%d%C(reset)%n''%C(white)%s%C(reset) %C(dim white)- %an%C(reset)'
    lg3-specific = log --graph --abbrev-commit --decorate --format=format:'%C(bold blue)%h%C(reset) - %C(bold cyan)%aD%C(reset) %C(bold green)(%ar)%C(reset) %C(bold cyan)(committed: %cD)%C(reset) %C(auto)%d%C(reset)%n''          %C(white)%s%C(reset)%n''          %C(dim white)- %an <%ae> %C(reset) %C(dim white)(committer: %cn <%ce>)%C(reset)'

git lg
git lg

git lg2
git lg2

git lg3
git lg3

courtesy of: stackoverflow.com/a/34467298/504836

Collapse
 
adityavarma1234 profile image
Aditya Varma

There seems to be a typo in the last command for

git log --online --graph --color

it should be

git log --oneline --graph --color

Collapse
 
drews256 profile image
Andrew Stuntz

Yes! My bad. I'll fix it when I get a chance.

Collapse
 
wbern profile image
William Bernting

Maybe you'd enjoy git-screensaver. 🙂

 
drews256 profile image
Andrew Stuntz

slow because it still uses Electron AFAIK

Electron apps don't have to be slow....

Thread Thread
 
tux0r profile image
tux0r

Name one which is not...?

Thread Thread
 
drews256 profile image
Andrew Stuntz

Postman comes to mind.

Collapse
 
motss profile image
Rong Sen Ng

TIL --graph. Thanks.