7 ms·
A better git log
- john2x 13y agoOff 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 13y agoMy 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.
- deleted 13y ago[deleted]
- qznc 13y agoI use something similar so often that I made myself a shell alias "gl".
- graup 13y agoMe too. And I got it from here: http://alias.sh/compact-colorized-git-log http://alias.sh/compact-colorized-git-log Which is almost the same as mentioned in this post.
- grapjas 13y agoI 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?
- manojlds 13y agoWant better? Use tig - https://github.com/jonas/tig https://github.com/jonas/tig
- Duhck 13y agoThis. Tig is amazing
- MetaCosm 13y agoEverytime 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.
- Domenic_S 13y agoI'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!!
- drewblaisdell 13y agoNot 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.
- argonaut 13y agoBe careful with that kind of assumption. I've never seen this before, and found it very useful.
- ChiperSoft 13y agoMany 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 13y agoclearly 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?
- philbo 13y agoHere 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
- glenjamin 13y agoyou 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
- leephillips 13y agoWhat terminal does this work in? I just got raw escape codes.
- philbo 13y agoOh, 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 13y agoThose 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 13y agoWhich PAGER are you using? If it's less, try setting PAGER='less -R', or LESS=-R to enable raw control character output.
- magnetikonline 13y agoI use a slight variation to this: https://github.com/magnetikonline/dotfiles/blob/master/.gitconfig 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.
- lmm 13y agoWhat 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.
- chalst 13y agoYes, 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.
- rquirk 13y ago`git whatchanged` is what you want, it shows the files changed and the commit message.
- deleted 13y ago[deleted]
- h2s 13y agogit log --stat
- glenjamin 13y agotry 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.
- rane 13y agoI 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 13y agoFYI: %h implies --abbrev-commit and %cr implies --relative-date/--date=relative (Commit date Relative).
- jacquesm 13y agohttps://news.ycombinator.com/item?id=4130494 https://news.ycombinator.com/item?id=4130494
- reidmain 13y agoSo everyone who started visiting Hacker News 352 days ago shouldn't get to see this on HN?
- klibertp 13y agoNo, but he may be interested in the previous comments. That's where most good things are, anyway ;)
- reidmain 13y agoGood call. I hadn't thought of that. Reddit has given me a cynical outlook when someone points out that something is a "repost".
- jacquesm 13y agoWhat gave you that idea?
- reidmain 13y agoReddit has given me a cynical view when someone points out "This has been posted before!". I apologize jacquesm.
- drinchev 13y agoYep, first thing I also thought is "That's old!"
- jb55 13y agoFor a high level overview of your branches I still think http://stackoverflow.com/questions/1057564/pretty-git-branch-graphs http://stackoverflow.com/questions/1057564/pretty-git-branch... is the best git log
- the_mitsuhiko 13y agoPrettier with indentation: http://i.imgur.com/9olL8Ds.png http://i.imgur.com/9olL8Ds.png Source: https://github.com/mitsuhiko/dotfiles/blob/master/git/gitconfig https://github.com/mitsuhiko/dotfiles/blob/master/git/gitcon...
- rjzzleep 13y agoi 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 13y agoWhat is the purpose of your "st" alias?
- rjzzleep 13y agogood catch, that's pretty much a leftover from pre git status --short times, thanks
- joeshaw 13y agoI 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.
- isaacb 13y agoWhat is that color scheme? It's pretty great.
- jakub_g 13y agoMy 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.
- rjzzleep 13y agoi 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
- stblack 13y agoCoderwall: meta content='width=device-width,initial-scale=1.0,maximum-scale=1.0' Really??
- oceanician 13y agoCheers for the reminder. I've definitely seen this before, but had completely forgot to set it up on my new laptop. Good post.
- languagehacker 13y agoIs this really anything new?
- officialjunk 13y agoNo love for gitk?