I have been tinkering with git
aliases for some log
commands. I have most of what I'd like (credit here), but I'm having trouble with one piece. When I call…
git log --graph --format=format:'%h - [%ar] %s%+d'
…I get…
* ab123f - [6 hours ago] Fix the references
| (HEAD, origin/master, master)
* bc123f - [8 hours ago] New build syntax
* cd123f - [10 hours ago] Initial import
…where %+d
adds a new line and puts the --decorate
tags on it if they exist. I would rather have the tags to be in line with the time stamp instead, like so:
* ab123f - [6 hours ago] Fix the references
| (HEAD, origin/master, master)
* bc123f - [8 hours ago] New build syntax
* cd123f - [10 hours ago] Initial import
How do I accomplish this? I do not want a bonus newline if there are no --decorate
tags. I've been experimenting with various format placeholders: %+d
, %-d
, %+ d
(which doesn't work); permutations of %>(<N>)
, %>>(<N>)
; and so on, but I can't get it to do what I want.
Colors and further commit info had been removed for simplicity, but they seem to interfere with torek's answer. The full command is below:
git log --graph --format=format:'%C(bold yellow)%h%C(reset) - %C(green)(%ar)%C(reset) %s %C(white)<%an>%C(reset)%C(auto)%+d%C(reset)'
[m
at the end of the first line and no second line for reasons that are unclear to me. Do you know why that is? – Shankle