Wang Yugui <wangyugui@xxxxxxxxxxxx> writes: > [root@T640 ~]# git log '--pretty=format:%h: %an: %s' -- hw/ >a.txt This is an expected behaviour. Notice that the format string given above does not end in LF by itself (its final placeholder is the subject string without LF at the end). LF you'd see in the output all come from the "log" machinery and not from the format string. When the machinery adds LFs, there are "separator" and "terminator" behaviour, the former of which adds a separating LF between each item, while the latter adds a terminating LF after each item. "--pretty=format" is defined to use a separator semantics that is suited to show multi-line items, each of which ends in LF on its own (think of --pretty=format:"by %an%n%b"). Using terminator behaviour you'd get an useless extra LF at the end for such a format, and separator behaviour lets you avoid it. "git log --help" and find "tformat", to learn more. --format=<fmt>, instead of --pretty=format:<fmt>, may also help.