Live data from Hacker News

Git log – The good parts

zwischenzugs.com

1–10 of 86 posts

Re: Git log – The good parts

#2
Commands in the article:

    git clone https://github.com/ianmiell/cookbook-openshift3-frozen
    cd cookbook-openshift3-frozen
    git log
    git log --oneline
    git log --oneline --decorate
    git log --oneline --decorate --all
    git log --oneline --decorate --all --graph
    git log --oneline --decorate --all --graph --simplify-by-decoration
    git log --oneline --decorate --all --graph --stat
    git log -G 'chef-client' --graph --oneline --stat
    git log -G 'chef-client' --graph --oneline --stat --pickaxe-all

Re: Git log – The good parts

#4

Commands in the article: git clone https://github.com/ianmiell/cookbook-openshift3-frozen cd cookbook-openshift3-frozen git log git log --oneline git log --oneline --decorate git log --oneline --decorate --all git log --oneline --decorate --all --graph git log --oneline --decorate --all --graph --simplify-by-decoration git log --oneline --decorate --all --graph --stat git log -G 'chef-client' --graph --oneline --stat…

A quick mnemonic I read on StackOverflow[1] some time ago:

   When using git log, do it like "a dog"
   git log --all --decorate --oneline --graph
I must say I had forgotten about the `--all` part, but the article mentions that it should be on by default if running interactively in the terminal, at least with recent versions of git.

[1]It might have been https://stackoverflow.com/questions/1057564/pretty-git-branc... but I am not 100% sure.

Re: Git log – The good parts

#5
In case anyone finds these useful, here are some git log aliases I use everyday.

    FORMAT="%C(auto)%h %C(magenta)%ad %C(cyan)%an%C(auto)%d %s"
    PRETTY="--pretty=format:'$FORMAT' --date=short"
    git config --global alias.lga "log --graph --all $PRETTY"
    git config --global alias.lg "log --graph $PRETTY"
    git config --global alias.la "log --all $PRETTY"
    git config --global alias.ll "log $PRETTY"
    git config --global alias.lf "log --pretty=fuller --stat"
There are two interesting things to note here:

• Since the --decorate option is now enabled by default (at least since Git 2.13), I don't have the --decorate option in my aliases. You may have to add them if you are using an older version of Git.

• Often while looking at the commit log, I need to know the commit date and the committer name which --oneline option does not show by default, so instead of using the --oneline option, I am formatting the one-liner logs myself with the `--pretty=format:` option to see these details.

The --simplify-by-decoration option is a nice one, something I can add to my list of aliases.

I have these aliases and a few other useful aliases documented in a bonus section named "Nifty Commands" in a fork and pull request workflow document I shared on Hacker News about a month ago. Here is the URL: https://github.com/susam/gitpr.

Re: Git log – The good parts

#6
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)%Creset' --abbrev-commit"
I strongly recommend both.

--

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

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

Post reply on HN