0

I use the following alias which I like a lot:

git config --global alias.dag 'log --oneline --decorate --all --graph'

It gives me something link this:

* 1234  (HEAD->master, origin/master) Commit Message

When I use emacs magit I also get the user name and date of commit:

* 1234  (HEAD->master, origin/master) Commit Message    MyName   date

Anyone know the best way to modify the alias to provide the extra information? It would also helped if it was column aligned like emacs does.

eflanigan00
  • 481
  • 4
  • 12

3 Answers3

2

You could do something like this:

git config --global alias.dag 'log --pretty=format:"%C(green)%h\\ %C(yellow)[%ad]%Cred%d\\ %Creset%s%Cblue\\ [%cn]" --decorate --date=local'

This gives you a nice one-liner with the columns you wanted. Each column is also a different color for the purpose of clarity.

--date=local will show the current date and time, but you can use other options with the --date flag: --date=(relative|local|default|iso|rfc|short|raw)

More info on git log --date can be found here: How to change git log date formats

Dan Kreiger
  • 5,358
  • 2
  • 23
  • 27
  • This is nice! I'm not getting the width to align. I get a single \ in my output. – eflanigan00 Jul 11 '17 at 16:06
  • Oh - the \ is there for styling purposes. You can delete them in the command if you want: `git log --pretty=format:"%C(green)%h %C(yellow)[%ad]%Cred%d %Creset%s%Cblue [%cn]" --decorate --date=local ` You can old add the `--graph` flag if you want to see additional information. You have that flag in your post. – Dan Kreiger Jul 11 '17 at 16:15
1

The "Commit Formatting" section of git log documentation has all the answers.

This command produces the output you need without colors:

git log --all --graph --format="%H %d %s %cn %cd"

The format placeholders:

  • %H - the commit hash; use %h to get the abbreviated commit hash;
  • %d - the ref names, like the --decorate options produce;
  • %s - the commit subject;
  • %cn - committer name;
  • %cd - committer date (the format respects the --date= option);
    use %cD, %ct, %cr, %ci, %cI for other formats.

Read more about the format placeholders in the "Pretty Formats" section of the documentation.

axiac
  • 68,258
  • 9
  • 99
  • 134
1

This works great, thank you guys for the great start:

git config --global alias.dag 'git log --pretty=format:"%C(blue)%h %C(green)%d %<(60)%Creset%s %<(20)%C(yellow)%cn %C(green)%ad" --decorate --all --graph --date=local'
eflanigan00
  • 481
  • 4
  • 12