News for hackers. Stuff that matters.
Re:Git log – The good parts by TeMPOraL on Monday March 26, 2018 @04:34AM (#16677497)
For those increasingly rare times I'm not using Magit[0], I have a "git lg" alias I found once through HN[1]:

  git config --global alias.lg "log --color --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit"
I strongly recommend both.

--

[0] - https://magit.vc/

[1] - https://coderwall.com/p/euwpig/a-better-git-log

Re:Git log – The good parts by peff on Monday March 26, 2018 @05:27AM (#16677674)
You should probably avoid `--color`, as it turns on color unconditionally, even if output is going to a file. In older versions of Git the %C color placeholders were unconditional anyway. In modern Git, they respect the normal auto-coloring settings.

You can also drop `--abbrev-commit`, since `%h` abbreviates by default (use `%H` if you want the full hash).

Re:Git log – The good parts by dalore on Monday March 26, 2018 @05:49AM (#16677743)
For the lazy:

  git config --global alias.lg "log --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset'"
Re:Git log – The good parts by garborg on Monday March 26, 2018 @09:36AM (#16678718)
We must have started from the same source. I've since added displaying message bodies by default, but similar otherwise:

lg = log --graph --date=relative --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset%n%w(0,4,4)%-b%n%n%-N'

Re:Git log – The good parts by knux on Monday March 26, 2018 @12:13PM (#16679944)
You can still add color when not piping or writing to a file with `--color=auto`.

      git config --global alias.lg "log --color=auto --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset'"
Re:Git log – The good parts by yes_or_gnome on Monday March 26, 2018 @12:25PM (#16680048)
This is likely to be said, "`--color=auto` is the default setting, so it's not needed." However, it's good to include it here because some users may have changed their default configuration to disable colors. This way `git log` works as their standard workflow and `git lg` for when they need a bit of color.
Re:Git log – The good parts by heipei on Monday March 26, 2018 @08:25AM (#16678291)
I use the following since it keeps the abbreviated hash and date of the commit in their own "columns", making it easy to skim:

  git log --date=short --pretty=format:"%C(124)%ad %C(24)%h %C(34)%an %C(252)%s%C(178)%d"
Re:Git log – The good parts by twic on Monday March 26, 2018 @02:19PM (#16681141)
Since we're sharing:

    [pretty]
    	lg = %C(red)%h%C(reset) %C(green)%ci%C(reset) %s %C(bold blue)-- %an%C(reset)%C(yellow)%d%C(reset)
    	lge = %C(red)%h%C(reset) %C(green)%ci%C(reset) %s %C(bold blue)-- %an <%ae>%C(reset)%C(yellow)%d%C(reset)
    	reflg = %C(red)%h%C(reset) %C(green)%ci%C(reset) %s %C(bold blue)-- %an%C(reset) %C(yellow)(%gd)%C(reset)
    [alias]
    	lg = log --pretty=lg
    	glg = log --graph --pretty=lg
    	slg = stash list --pretty=reflg
    	blg = branch --format '%(color:red)%(objectname:short)%(color:reset) %(color:green)%(committerdate:iso)%(color:reset) %(subject) %(color:bold blue)-- %(authorname)%(color:reset) %(color:yellow)(%(refname:short))%(color:reset)'
lg is the normal log, glg is with the graph, slg lists my stashes in the same format (i find the date really helpful), and blg does the same for branches.

blg can't reuse a pretty definition because it uses a completely different formatting language. The fact that Git contains two different but largely equivalent formatting languages is kind of emblematic of its whole design, really.

Like heipei, i put the fixed-width bits on the left so that they line up. I try to use consistent and distinctive colours for everything; mostly that's obvious, but yellow draws an equivalent between branch names for the normal and branch logs, and stash refs for the stashes. Including committer name for stashes is perhaps foolish consistency, although it would be useful if you do pair programming and use something like git-duet.

Re:Git log – The good parts by sedatk on Tuesday March 27, 2018 @02:12PM (#16691216)
> The fact that Git contains two different but largely equivalent formatting languages is kind of emblematic of its whole design, really.

tip of the iceberg.

Re:Git log – The good parts by Cyranix on Monday March 26, 2018 @03:48PM (#16681873)
I haven't seen anyone share an author-filtering use case yet, so here's a lightly-edited version of my "git mine" alias:

  log --no-merges --date=short --author="cyranix" --stat
This allows me to skim through my own recent changes.

"--no-merges" is included in just about every log invocation I run; in a continuous integration workflow, I generally don't find merge commit info to be all that informative.

As an additional tip, the "-n <count>" form of limiting the history can be shortened to "-<count>". For example, reviewing the diff of the last two commits can be achieved with "git log -p -2".

Re:Git log – The good parts by Zardoz84 on Monday March 26, 2018 @06:36AM (#16677908)
I use a light variant from it :

  git config --global alias.lg "log --color --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit --date-order"
Re:Git log – The good parts by zeotroph on Monday March 26, 2018 @06:59AM (#16677976)
The difference is an added --date-order:

"Show no parents before all of its children are shown, but otherwise show commits in the commit timestamp order."

Re:Git log – The good parts by bhaavan on Monday March 26, 2018 @05:51AM (#16677753)
lol, I named my alias `git lol` because it is logs in one line.
Re:Git log – The good parts by Cthulhu_ on Monday March 26, 2018 @07:05AM (#16677993)
lol, I named mine 'git l' because I type it far too often.
Re:Git log – The good parts by codetrotter on Monday March 26, 2018 @10:01AM (#16678931)
I use two-letter bash aliases for all my most commonly used git commands.

    git status
    git diff
    git diff --cached
    git add -A
    git commit -m Hello
    git push
Is instead just

    st
    dp
    di
    aa
    cm Hello
    pu
Additionally I also have

    le
For

    git shortlog -s -e
which I don’t use very often but often enough that having an alias for it still makes sense
Re:Git log – The good parts by nojvek on Monday March 26, 2018 @10:27PM (#16684655)
I edited my inputrc to do a prefix search. So I just ‘git x’ where x is some letter, pressing up usually finds me what I want.

It still surprises me we don’t have good bash autocomplete.

Not sure how hard it is to create a shell but i’d do it in a heartbeat.

Re:Git log – The good parts by jquast on Wednesday March 28, 2018 @02:25AM (#16695802)
i think 'xonsh' aims to do that
Re:Git log – The good parts by alexmorenodev on Monday March 26, 2018 @10:09AM (#16678993)
Mine is only `gl`, but I edited my .zshrc for that.
Re:Git log – The good parts by OskarS on Monday March 26, 2018 @07:30AM (#16678064)
I named my custom logging command 'git ls', which is an idiotic name (that should list files or something), but I'm stuck with it now :)
Re:Git log – The good parts by hellofunk on Monday March 26, 2018 @10:02AM (#16678938)
mine is assigned to the bash alias "gl"
Re:Git log – The good parts by smoyer on Monday March 26, 2018 @06:18AM (#16677856)
Many of us at work have the following alias in our .gitconfig file:

lola = log --graph --decorate --pretty=oneline --abbrev-commit --all

This is similar to others posted here.

Re:Git log – The good parts by agumonkey on Monday March 26, 2018 @03:34PM (#16681742)
Have you tried other git UIs (IDE or not) ?

I wonder if there's one that is as good as magit (my opinion is no, but that's why I ask)

Re:Git log – The good parts by TeMPOraL on Tuesday March 27, 2018 @12:34AM (#16685276)
gitk 7-8 years ago, Github desktop app few years later. I used version control features in Eclipse and IntelliJ for SVN, but I believe the same interface maps to Git as well.

None of them even compare with Magit. They offer a small subset of Git features - unlike Magit, which gives you almost all of them, + some higher level abstractions (like "merge into"), and you're always one ! ! press away from entering a manual command. Also, the other interfaces I've used were mostly mouse based, whereas Magit just flows. Feels order of magnitude more efficient than anything else.

Re:Git log – The good parts by kqr on Tuesday March 27, 2018 @06:27AM (#16686952)
> you're always one ! ! press away from entering a manual command

Huh, I didn't know this. I'll probably live in Magit from now on.

Re:Git log – The good parts by TeMPOraL on Tuesday March 27, 2018 @06:34AM (#16686978)
Also useful: any time you find yourself wondering what did Magit just do, press $ to display raw output from git commands (lists the commands issued and their return codes, TAB expands them to full output).
Re:Git log – The good parts by agumonkey on Tuesday March 27, 2018 @11:12AM (#16689237)
I don't do it that often but I felt compelled to tip magit maintainer because it's just a beautiful and important piece of my emacs life.
Re:Git log – The good parts by TeMPOraL on Tuesday March 27, 2018 @11:25AM (#16689383)
Magit had a Kickstarter recently (yes, an Emacs mode on Kickstarter; I was shocked too), to raise funds for continued development. I dropped some cash there; after all, it helps me quite a lot to earn my paycheck.
Re:Git log – The good parts by agumonkey on Tuesday March 27, 2018 @12:27PM (#16690078)
is it because Kickstarter is contradictory to FSF mindset ?

I couldn't pay on KS so I asked him his paypal handle, but it was the KS campaign that motivated me. As you said, it's a great asset to the day of developpers (or any document maintainer under git)

Re:Git log – The good parts by TomK32 on Monday March 26, 2018 @07:00AM (#16677980)
I couldn't bare those relative times.

My prefered tool is `tig --all` which gives me a nice view of the repo with its branches.