Last Updated: April 07, 2019
·
11.36K
· jedschneider

glog - a git log alias for a decent view of your repo

The standard git log command is a pretty useless view of whats going on in your repo. Unless you want very specific info about a single commit.

commit dd13722c264a84e81ce15a6ec168c84d4db460ca
Merge: eec00b8 fa0cff4
Author: Rafael Mendonça França <rafaelmfranca@gmail.com>
Date:   Mon Sep 23 12:13:15 2013 -0300

    Merge pull request #10773 from wangjohn/link_and_routing_options

    Adding documentation and tests to ``polymorphic_url`` and ``link_to``

commit eec00b8c03273d006aa12505bde32e2a2547b670
Merge: 68d7a1e 9f82fb3
Author: Rafael Mendonça França <rafaelmfranca@gmail.com>
Date:   Mon Sep 23 08:11:26 2013 -0700

Mostly you care about the relative nature of named pointers, like branches and tags. You want to see what ancestor objects are in common, diverging development histories, and the probability of merge conflicts. You could use something like gitk or gitx for this, but you could also create an alias that gives you a nicer view into the things you care about.

From the HEAD of rails/rails (edited for protip formatting)

*    (HEAD, origin/master, origin/HEAD, master) dd13722 Rafael M...
*    França - Merge pull request #10773 from *    wangjohn/link_...
|\  
| *  fa0cff4 wangjohn - Adding documentation to +polymorphic_url...
* |    eec00b8 Rafael Mendonça França - Merge pull request #1198...
|\ \  
| * |  9f82fb3 wangjohn - Creating options for schema dumper.
* | |    68d7a1e Rafael Mendonça França - Merge pull request #12...
|\ \ \  
| * | |  21e6885 wangjohn - Small refactoring changes to generat...
* | | |    f04dd33 Rafael Mendonça França - Merge pull request #...
|\ \ \ \  
| * | | |  e8e08d6 Bogdan Gusiev - Fix some edge cases for AV `s...
|/ / / /  
* | | |  ed0b080 Rafael Mendonça França - Fix the documentation ...
* | | |  1c6bcef Rafael Mendonça França - Expand select document...
* | | |  0e9f0bd Rafael Mendonça França - Use ERB in the CHANGEL...
* | | |    377641e Rafael Mendonça França - Merge pull request #...
|\ \ \ \  
| * | | |  57bf92c Bogdan Gusiev - Ability to pass block to AV#s...
* | | | |  7ef2914 Rafael Mendonça França - No need to abbreviat...

To create this alias, add the following to your .gitconfig

[alias]
  glog = log --all --pretty='format:%d %Cgreen%h%Creset %an - %s' --graph

And run with: git glog from any git repo.

Credit due to Gary Fredericks for initial and ongoing improvements to this alias.

8 Responses
Add your response

https://github.com/jonas/tig is also really awesome

over 1 year ago ·

Nice tip !
I also second @halkeye plug about tig. I specially love to use it with etckeeper to manage my servers config versionning and admin log/journal.

over 1 year ago ·

Very nice. thanks @halkeye and @silopolis. Two new tools to check out. Have not heard of tig or etckeeper but both sound very useful. Feel free to link back your favorite tutorial on them!

over 1 year ago ·

I was just thinking on tig, unless you want to do something very specific.

over 1 year ago ·

i like this one, too:
log --color --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit

over 1 year ago ·

You may also want to use the --oneline and the --decorate native options, in case you need to use git-log on a machine where you don't have your own aliases.

over 1 year ago ·

@dporto99 and @likeyn related comments here. after playing with tig a bit, i really like it, but it is a dependency, where as glog is just an alias and easily configurable to your own taste. On the dependency note: While you may not always have access to create your own aliases on a remote machine or install a dependency like tig, you probably have the ability to fetch the git data. So you can always run the glog command, or tig for that matter, for a remote history by specifying the branch or checking it out, eg git checkout production/master && git glog

over 1 year ago ·

Thanks!

over 1 year ago ·