It’s possible to customize the formatting of git log with --pretty
. However I can’t find a way to display the body without trailing newline. Is it possible?
I would like to be able to display my log like this:
dc121234 Add some stuff
2349823f Update things
23498fe2 Add bugs
It’s important to add bug to your code
12398aab Clear thing
With --pretty="%h %s% b"
I’m nearly there, but this is what I got:
dc121234 Add some stuff
2349823f Update things
23498fe2 Add bugs
It’s important to add bug to your code
12398aab Clear thing
And if I want to add some more empty space with --pretty="%h %s% b%n"
(I added a %n
between %s
and %b
), I get an unwanted double newline after the multilines commit message:
dc121234 Add some stuff
2349823f Update things
23498fe2 Add bugs
It’s important to add bug to your code
12398aab Clear thing
Is there a way to remove the extra trailing newline added after the %b
?
CodePudding user response:
--pretty=
defaults to tformat
, with terminator newlines. --pretty=format:%h\ %s%n%b%-C
won't add an extra newline at the end and will eat all the trailing newlines on the body.