Home > Enterprise >  How can I get the git log entry without indenting?
How can I get the git log entry without indenting?

Time:11-06

In git I commit

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

git log shows

commit 3d640cbff57a6da500e40bba9dc20fd145975119 (HEAD -> main)
Author: me <[email protected]>
Date:   Fri Nov 5 12:00:22 2021 -0700

    this
    is
    my
    msg

but what I want is

commit 3d640cbff57a6da500e40bba9dc20fd145975119 (HEAD -> main)
Author: me <[email protected]>
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.

CodePudding user response:

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 <

  •  Tags:  
  • git
  • Related