
A better git log - 6ren
https://coderwall.com/p/euwpig
======
manojlds
Want better? Use tig -
[https://github.com/jonas/tig](https://github.com/jonas/tig)

~~~
Domenic_S
I'm so annoyed. I've heard "tig is amazing" so I go to github... hmm, no
screenshots or examples. Oh, there's a homepage. Compile instructions but also
no screenshots or examples.

" _Tig is a git repository browser that additionally can act as a pager for
output from various git commands._ "

It happens all over github. Even UI projects fall prey to this problem, which
is especially egregious. I want to grab these project owners by the shoulders,
shake them, and yell DON'T YOU WANT ME TO USE YOUR PROJECT? THEN SHOW ME WTF
IT DOES!!

~~~
isaacb
There are definitely screenshots on the website
([http://jonas.nitro.dk/tig/screenshots/](http://jonas.nitro.dk/tig/screenshots/))

~~~
Domenic_S
Oh I see, in the screenshots directory. That's nice. Point still stands, put
your screenshots front and center.

------
the_mitsuhiko
Prettier with indentation:
[http://i.imgur.com/9olL8Ds.png](http://i.imgur.com/9olL8Ds.png)

Source:
[https://github.com/mitsuhiko/dotfiles/blob/master/git/gitcon...](https://github.com/mitsuhiko/dotfiles/blob/master/git/gitconfig)

~~~
rjzzleep
i like your config i'll borrow some of that, here's my current one

[https://gist.github.com/fishman/091d32da731c8b841c94](https://gist.github.com/fishman/091d32da731c8b841c94)

EDIT: I either already did many many moons ago, or we would had the same
master :p

~~~
ChiperSoft
What is the purpose of your "st" alias?

~~~
rjzzleep
good catch, that's pretty much a leftover from pre

    
    
        git status --short
    

times, thanks

------
jacquesm
[https://news.ycombinator.com/item?id=4130494](https://news.ycombinator.com/item?id=4130494)

~~~
reidmain
So everyone who started visiting Hacker News 352 days ago shouldn't get to see
this on HN?

~~~
klibertp
No, but he may be interested in the previous comments. That's where most good
things are, anyway ;)

~~~
reidmain
Good call. I hadn't thought of that. Reddit has given me a cynical outlook
when someone points out that something is a "repost".

------
john2x
Off topic, but what's with the trend of not showing dates on blogs/blogging
services? Just overlooked or hidden on purpose? Even the comments don't have
dates.

~~~
a3n
My guess is that you're less likely to read something if you judge it out of
date by the post date. But I hate it.

------
philbo
Here are two variations that I find useful day-to-day.

1\. Graph showing commits on all branches, decorated with branch and tag
names, short commit hashes, committer name and commit comment:

    
    
        git log --graph --all --abbrev-commit --pretty=format:'%C(red)%d%x20%C(yellow)%h%x20%C(green)%an%x20%Creset%s'
    

2\. List commits in HEAD that aren't in master:

    
    
        git log --abbrev-commit --pretty=format:'%C(yellow)%h%x20%C(green)%an%x20%Creset%s' master..HEAD

~~~
leephillips
What terminal does this work in? I just got raw escape codes.

~~~
philbo
Oh, I had no idea it wasn't portable, sorry. I'm using iTerm2 on OSX, but
maybe worth trying them without the colouring:

    
    
        git log --graph --all --abbrev-commit --pretty=format:'%d%x20%h%x20%an%x20%s'
        git log --abbrev-commit --pretty=format:'%h%x20%an%x20%s' master..HEAD

~~~
leephillips
Those work, thanks. I'm on Linux using xfce4-terminal at the moment. There's
probably a way to get the color codes to work, but I don't know it.

~~~
nuxi
Which PAGER are you using? If it's _less_ , try setting _PAGER= 'less -R'_, or
_LESS=-R_ to enable raw control character output.

~~~
leephillips
Bingo! Nothing to do with the terminal at all! Thanks!

------
lmm
What I want is filenames in the git log, just a list of which files were
touched in each commit. My messages aren't distinct enough without them.

~~~
glenjamin
try one of the following:

    
    
        git log --stat
        git log --numstat
        git log --name-only
    

These flags can be passed to most git commands which show revisions, including
diff and show.

~~~
chalst
Sure, but they can't be integrated into a line-per-commit log without fiddly
scripting.

~~~
taeric
What is wrong with git whatchanged? Will use your pretty format for the
message, but then show the files. Right?

~~~
chalst
Is it possible to get one line per commit from this? I can only get one line
per file.

By one line per commit, I mean something along the lines of:

    
    
        56c6861 - add reflist (4 months ago: joe) Joe/Manu.bbl Joe/Manu.bib Joe/Manu.bst ...
        5ed70cc - (origin/master) add tests; change .gitignore (5 months ago: cas) ./.gitignore test/integ.lua test/refs ...
        d3c5de1 - replace Manifest; add converter (5 months ago: cas) ./Manifest maked/tex2html.lua maked/tex2html.cfg

~~~
taeric
Apologies for not responding on this. I am not aware of anything that does
this right off... Would probably be pretty easy to script. If you are still
interested, I could probably get the basics of this rolling.

~~~
chalst
Thanks. I can script this as well - there's nothing fundamentally tricky here,
but generating nice output is usually fiddly.

------
magnetikonline
I use a slight variation to this:
[https://github.com/magnetikonline/dotfiles/blob/master/.gitc...](https://github.com/magnetikonline/dotfiles/blob/master/.gitconfig)
more formatting/color that anything.

As noted below, tig is well worth the install for getting around your
logs/diffs on the command line.

------
jakub_g
My preferences:
[http://i.imgur.com/UtxK6LZ.png](http://i.imgur.com/UtxK6LZ.png) (source in my
github/dotfiles; this is suitable mostly for linear history without merges).
Displays 10 items by default, for more, I write explicitly from command line.

------
jb55
For a high level overview of your branches I still think
[http://stackoverflow.com/questions/1057564/pretty-git-
branch...](http://stackoverflow.com/questions/1057564/pretty-git-branch-
graphs) is the best git log

------
rane
I prefer my own alias over that, less clutter:

    
    
      glg='git log --pretty=format:'\''%Cred%h%Creset%C(yellow)%d%Creset %s %Cgreen(%cr)%Creset'\'' --abbrev-commit --date=relative'

~~~
graywh
FYI: %h implies --abbrev-commit and %cr implies --relative-
date/\--date=relative (Commit date Relative).

------
qznc
I use something similar so often that I made myself a shell alias "gl".

~~~
grapjas
I do the same for various other git commands, such as git checkout ('gc').

The only problem is that this breaks git tabcomp. Haave you (or anyone else)
dealt with this?

~~~
misnome
I choose a middle approach - rather than making loads of new base commands, I
just use the aliases, and only for the really common commands

> git co > git st > git ci

~~~
ionforce
Fellow git aliaser, consider shell aliasing git to g!

------
oceanician
Cheers for the reminder. I've definitely seen this before, but had completely
forgot to set it up on my new laptop. Good post.

------
stblack
Coderwall: meta content='width=device-width,initial-scale=1.0,maximum-
scale=1.0'

Really??

------
rjzzleep
i use this

lg = log --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %C(bold
white)%s%Creset %Cgreen(%cr) %C(blue)@%an%Creset' \--abbrev-commit
--date=relative

tig is neat, i need to port it

------
languagehacker
Is this really anything new?

------
officialjunk
No love for gitk?

------
drewblaisdell
Not only is this a repost, I have seen it on Hacker News _several_ times over
the past year. Anyone who is searching for a better Git log will find one
without the help of free advertisement on the front page.

~~~
ChiperSoft
Many git novices don't know that the log output can even be changed, and
aren't likely to be searching for an alternative syntax. Don't assume that
just because you know something, everyone else does, an that the training is
useless.

Additionally, the discussions that this post created here in the comments have
already given me three new aliases that I didn't know we're possible.

~~~
troll2
clearly you're not very imaginative. not thinking or realizing you can change
the output is naive. there are so many people writing up the same hints it's
almost impossible not to run into something like this daily. if you seriously
rely on 'discussions' to improve your knowledge you're not really thinking for
yourself, are you?

