3

In Gitk, showing a commit gives output like this:

Author: ...
Committer: ...
Parent: ...auth/parser)
Parent: ... (Merge branch '...')
Child:  ...
Branches: remotes/me/foo, foo

Is there a way to get this kind of output in git log? Using git log --graph gives similar information, but in my repository with long-lived branches, it can take a lot of scrolling to find which branch a commit was on.

(A similar question to How can I show the name of branches in `git log`?)

Community
  • 1
  • 1
Steve Bennett
  • 114,604
  • 39
  • 168
  • 219

1 Answers1

5

I use this:

git log --pretty=format:\"%h %ad [%an] %s%d\" --graph --date=short
--all --date-order

I added alias to my global .gitconfig

[alias]
    hist = log --pretty=format:\"%h %ad [%an] %s%d\" --graph --date=short --all --date-order

and can call simple git hist

It makes very pretty-to-read revisions tree with short commits hash, author, date, branches, HEADs etc on one line

radistao
  • 14,889
  • 11
  • 66
  • 92
  • 3
    I use something similar, but "%d" only gives labels the tip of each branch. I was hoping for something which would label every commit. – Steve Bennett May 21 '12 at 05:01
  • The one I use: git log --pretty='%Cblue%h%C(cyan)%d%Cred %cn %Cgreen %ar %Creset %s' – Steve Bennett May 21 '12 at 05:06
  • @radisto, I tried your command. It gives an error: fatal: ambiguous argument '%ad': unknown revision or path not in the working tree. Use '--' to separate paths from revisions, like this: 'git [...] -- [...]'. I am using git version 1.9.3 – user674669 Feb 13 '15 at 00:19
  • looks like you use some additional log formatting, which ambiguous with '%ad'. see http://superuser.com/questions/273570/git-log-alias-fatal-ambiguous-argument-ad-unknown-revision-or-path – radistao Feb 13 '15 at 07:21
  • 1
    It doesn't show the branches on all commits, only on the last ones. – peterh Mar 21 '17 at 09:48