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
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
The quotes will save you - just put the close quote on the next line, like:
git log --pretty=tformat:"%ai %s
" >log.log
and it should work.
Alternately, under the PRETTY FORMATS heading of git log --help
it lists:
· %m: left, right or boundary mark
· %n: newline
· %%: a raw %
Though apparently a 'newline' is a unix newline so on windows you'll want to use the direct hex codes like:
git log --pretty=tformat:"%ai %s%x10%x13" >log.log
For those making Windows batch files with git remember to convert single % to double %%. Also add hex for Carriage Return and Line feed
for example
git log --pretty=tformat:"%ai %s%x0D%x0A" >log.log
converted for window batch file
git log --pretty=tformat:"%%ai %%s%x0D%x0A" >log.log
The reason is that git uses LF as a separator while notepad and most windows application uses CRLF. The following script enabled me to produce a file with all changes.
del files.txt >nul 2>nul
git show --pretty="format:" --name-only HEAD > changes.txt
for /F "tokens=*" %%A in ('type "changes.txt"') do echo %%A >> files.txt
I was in a similar situation just now, I wanted to add a line break because cat -e
would mess with the formatting when running the command in a bash script. I had tried the suggestions in this page and others more, but what really solved my problem was just removing format:
. Typing only git log --pretty="%H"
adds a normal line break after the last result.
You can use
%n
as a new line: