1

I am learning Git. I wrote the command:

$ git log --pretty=format:"author: %an, %ae\ncommiter: %cn, %ce\nInfo: %s"

I expected \n will be interpreted like a new line char:

author: CharliePoole, charliepoole@gmail.com
commiter: CharliePoole, charliepoole@gmail.com
Info: Merge pull request #563 from nunit/issue-562

But I get this output:

author: CharliePoole, charliepoole@gmail.com\ncommiter: CharliePoole,
charliepoole@gmail.com\nInfo: Merge pull request #563 from nunit/issue-562

Also I read this before:

Escaping strings isn't Git's job; git log doesn't have anything that'll help you do that.

So, is it impossible for escape chars too?

Community
  • 1
  • 1
Andrey Bushman
  • 11,712
  • 17
  • 87
  • 182

1 Answers1

1

You are mixing two different kind of things. From man git:

The format: format allows you to specify which information you want to show. It works a little bit like printf format, with the notable exception that you get a newline with %n instead of \n.

Answer: use %n

hek2mgl
  • 152,036
  • 28
  • 249
  • 266