How can I get the git log entry without indenting?

Viewed 294

In git I commit

git commit -m 'this
quote> is
quote> my
quote> msg
quote> '

git log shows

commit 3d640cbff57a6da500e40bba9dc20fd145975119 (HEAD -> main)
Author: me <me@me.org>
Date:   Fri Nov 5 12:00:22 2021 -0700

    this
    is
    my
    msg

but what I want is

commit 3d640cbff57a6da500e40bba9dc20fd145975119 (HEAD -> main)
Author: me <me@me.org>
Date:   Fri Nov 5 12:00:22 2021 -0700

this
is
my
msg

or to put it another way, I want the log message in a way suitable for copying and pasting into a new log message whereas by default the message is indented so then I have to un-indent it manually before being able to actually use it.

2 Answers

git log has the --format=format:%B option which will give you the raw commit message without indents.

To get it to look like what you have in your example, it would be

git log --format=format:"commit %H %d%nAuthor: %an <%ae>%nDate: %aD%n%n%B"

The shortest command line I found is:

git log --pretty=e

which is a shorthand for:

git log --pretty=email
Related