Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

git log with line break when exported to text file

How do I add a line break for my custom git log?

git log --pretty=tformat:"%ai %s" > log.log

I want a line break after %s

like image 942
sceiler Avatar asked Nov 11 '14 20:11

sceiler


People also ask

How do you break a line in a text file?

CR and LF are control characters or bytecode that can be used to mark a line break in a text file. CR = Carriage Return ( \r , 0x0D in hexadecimal, 13 in decimal) — moves the cursor to the beginning of the line without advancing to the next line.

How do I access Git logs?

The command for that would be git log -n where n represents the number up to which commit you to want to see the logs.

What is git log command?

Git log is a utility tool to review and read a history of everything that happens to a repository. Multiple options can be used with a git log to make history more specific. Generally, the git log is a record of commits.


2 Answers

You can use %n as a new line:

git log --pretty=tformat:"%ai %s%n" > log.log
like image 132
Gene Gotimer Avatar answered Oct 11 '22 20:10

Gene Gotimer


Pjz's answer is not quite right for Windows, but with a little playing around I got it to work. The 10 and 13 characters needed to be reversed, and they needed to be in proper hex format:

git log --pretty=tformat:"%ai %s%x0D%x0A" >log.log
like image 37
Stephen Naughton Avatar answered Oct 11 '22 20:10

Stephen Naughton