News for hackers. Stuff that matters.
Re:A better git log by manojlds on Friday June 07, 2013 @05:08AM (#5837960)
Want better? Use tig - https://github.com/jonas/tig
Re:A better git log by Domenic_S on Friday June 07, 2013 @02:51PM (#5840875)
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!!

Re:A better git log by isaacb on Friday June 07, 2013 @03:34PM (#5841124)
There are definitely screenshots on the website (http://jonas.nitro.dk/tig/screenshots/)
Re:A better git log by Domenic_S on Friday June 07, 2013 @08:41PM (#5843067)
Oh I see, in the screenshots directory. That's nice. Point still stands, put your screenshots front and center.
Re:A better git log by Duhck on Friday June 07, 2013 @10:46AM (#5839185)
This. Tig is amazing
Re:A better git log by MetaCosm on Friday June 07, 2013 @11:58AM (#5839656)
Everytime I think a feature doesn't exist in tig, I search the docs for it... facepalm that I didn't realize it could do that and love it ever so much more.
Re:A better git log by the_mitsuhiko on Friday June 07, 2013 @08:59AM (#5838588)
Re:A better git log by joeshaw on Friday June 07, 2013 @12:27PM (#5839836)
I use something similar:

    [alias]
        lt = log --graph --pretty=changes
    [pretty]
        changes = format:%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset
It's nice to be able to separate the format specifier from the alias itself. Makes the configuration a lot cleaner.
Re:A better git log by rjzzleep on Friday June 07, 2013 @10:20AM (#5839024)
i like your config i'll borrow some of that, here's my current one

https://gist.github.com/fishman/091d32da731c8b841c94

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

Re:A better git log by ChiperSoft on Friday June 07, 2013 @10:55AM (#5839238)
What is the purpose of your "st" alias?
Re:A better git log by rjzzleep on Sunday June 09, 2013 @02:17PM (#5849880)
good catch, that's pretty much a leftover from pre

    git status --short
times, thanks
Re:A better git log by isaacb on Saturday June 08, 2013 @12:14AM (#5843764)
What is that color scheme? It's pretty great.
Re:A better git log by jacquesm on Friday June 07, 2013 @06:43AM (#5838172)
Re:A better git log by reidmain on Friday June 07, 2013 @12:43PM (#5839931)
So everyone who started visiting Hacker News 352 days ago shouldn't get to see this on HN?
Re:A better git log by klibertp on Friday June 07, 2013 @01:20PM (#5840209)
No, but he may be interested in the previous comments. That's where most good things are, anyway ;)
Re:A better git log by reidmain on Saturday June 08, 2013 @05:34PM (#5846441)
Good call. I hadn't thought of that. Reddit has given me a cynical outlook when someone points out that something is a "repost".
Re:A better git log by jacquesm on Saturday June 08, 2013 @06:57AM (#5844540)
What gave you that idea?
Re:A better git log by reidmain on Saturday June 08, 2013 @05:34PM (#5846443)
Reddit has given me a cynical view when someone points out "This has been posted before!". I apologize jacquesm.
Re:A better git log by drinchev on Saturday June 08, 2013 @07:48AM (#5844616)
Yep, first thing I also thought is "That's old!"
Re:A better git log by john2x on Friday June 07, 2013 @07:00AM (#5838213)
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.
Re:A better git log by a3n on Friday June 07, 2013 @08:56AM (#5838575)
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.
Re:A better git log by philbo on Friday June 07, 2013 @05:53AM (#5838058)
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
Re:A better git log by glenjamin on Friday June 07, 2013 @07:28AM (#5838289)
you can get a slightly more reliable list of commits that are in HEAD that aren't in master using --not:

    git log HEAD --not master
or the shorthand

    git log HEAD ^master
Re:A better git log by leephillips on Friday June 07, 2013 @08:31AM (#5838482)
What terminal does this work in? I just got raw escape codes.
Re:A better git log by philbo on Friday June 07, 2013 @09:03AM (#5838608)
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
Re:A better git log by leephillips on Friday June 07, 2013 @09:20AM (#5838684)
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.
Re:A better git log by nuxi on Friday June 07, 2013 @10:28AM (#5839061)
Which PAGER are you using? If it's less, try setting PAGER='less -R', or LESS=-R to enable raw control character output.
Re:A better git log by leephillips on Friday June 07, 2013 @10:55AM (#5839234)
Bingo! Nothing to do with the terminal at all! Thanks!
Re:A better git log by lmm on Friday June 07, 2013 @06:17AM (#5838116)
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.
Re:A better git log by glenjamin on Friday June 07, 2013 @07:27AM (#5838282)
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.
Re:A better git log by chalst on Friday June 07, 2013 @07:36AM (#5838312)
Sure, but they can't be integrated into a line-per-commit log without fiddly scripting.
Re:A better git log by taeric on Friday June 07, 2013 @08:51AM (#5838556)
What is wrong with git whatchanged? Will use your pretty format for the message, but then show the files. Right?
Re:A better git log by chalst on Friday June 07, 2013 @08:53AM (#5838564)
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
Re:A better git log by taeric on Friday June 14, 2013 @11:59AM (#5880626)
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.
Re:A better git log by chalst on Wednesday June 19, 2013 @04:15AM (#5904333)
Thanks. I can script this as well - there's nothing fundamentally tricky here, but generating nice output is usually fiddly.
Re:A better git log by chalst on Friday June 07, 2013 @06:20AM (#5838121)
Yes, or at least the basename of the file that changed most. I think you can't include filenames using --pretty though, you'd have to write a new script.
Re:A better git log by rquirk on Friday June 07, 2013 @06:49AM (#5838184)
`git whatchanged` is what you want, it shows the files changed and the commit message.
Re:A better git log by h2s on Friday June 07, 2013 @07:26AM (#5838280)

    git log --stat
Re:A better git log by magnetikonline on Friday June 07, 2013 @05:58AM (#5838071)
I use a slight variation to this: https://github.com/magnetikonline/dotfiles/blob/master/.gitc... more formatting/color that anything.

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

Re:A better git log by jakub_g on Friday June 07, 2013 @09:37AM (#5838762)
My preferences: 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.
Re:A better git log by jb55 on Friday June 07, 2013 @07:58AM (#5838370)
For a high level overview of your branches I still think http://stackoverflow.com/questions/1057564/pretty-git-branch... is the best git log
Re:A better git log by rane on Friday June 07, 2013 @06:24AM (#5838134)
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'
Re:A better git log by graywh on Friday June 07, 2013 @11:39AM (#5839508)
FYI: %h implies --abbrev-commit and %cr implies --relative-date/--date=relative (Commit date Relative).
Re:A better git log by qznc on Friday June 07, 2013 @04:58AM (#5837944)
I use something similar so often that I made myself a shell alias "gl".
Re:A better git log by graup on Friday June 07, 2013 @05:47AM (#5838046)
Me too. And I got it from here: http://alias.sh/compact-colorized-git-log

Which is almost the same as mentioned in this post.

Re:A better git log by grapjas on Friday June 07, 2013 @05:49AM (#5838049)
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?

Re:A better git log by misnome on Friday June 07, 2013 @06:40AM (#5838166)
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

Re:A better git log by ionforce on Friday June 07, 2013 @09:50AM (#5838845)
Fellow git aliaser, consider shell aliasing git to g!
Re:A better git log by oceanician on Friday June 07, 2013 @10:36AM (#5839106)
Cheers for the reminder. I've definitely seen this before, but had completely forgot to set it up on my new laptop. Good post.
Re:A better git log by stblack on Friday June 07, 2013 @10:30AM (#5839074)
Coderwall: meta content='width=device-width,initial-scale=1.0,maximum-scale=1.0'

Really??

Re:A better git log by rjzzleep on Friday June 07, 2013 @10:17AM (#5839006)
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

Re:A better git log by languagehacker on Friday June 07, 2013 @12:06PM (#5839709)
Is this really anything new?
Re:A better git log by officialjunk on Saturday June 08, 2013 @03:30AM (#5844230)
No love for gitk?
Re:A better git log by drewblaisdell on Friday June 07, 2013 @05:12AM (#5837967)
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.
Re:A better git log by ChiperSoft on Friday June 07, 2013 @10:01AM (#5838919)
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.

Re:A better git log by troll2 on Friday June 07, 2013 @08:01PM (#5842919)
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?
Re:A better git log by argonaut on Friday June 07, 2013 @05:55AM (#5838063)
Be careful with that kind of assumption. I've never seen this before, and found it very useful.