Git Log > CHANGELOG.md yields strange characters

86 Views Asked by At

I use the following command to generate a CHANGELOG.md immediately before a commit:

git log --pretty=format:'%C(yellow)%h %Cred%ad %Cblue%an <%ae> %Cgreen%d %Creset%s' --date=short --graph > CHANGELOG.md

When I run the command directly, not > CHANGELOG.md, I get the expected pretty output:

|\
| * 97997cf 6 days ago Timothy Stephens <[email protected]>  bugzid:16451 new lockfile
* | 4245715 6 days ago Timothy Stephens <[email protected]>  bugzid:16451 added tag script v1, new lockfile
|/
* 98cc3a6 6 days ago Timothy Stephens <[email protected]>  bugzid:16451 include .lock for deploy, temporarily remove tests automatically running
* eaa8b2f 6 days ago Timothy Stephens <[email protected]>  bugzid:16451 removed submodulegit status
* 3b6c82f 6 days ago Timothy Stephens <[email protected]>  bugzid:16451 merge master 2014-11-13

But in the CHANGLOG.md, I'm getting strange ^[[34m characters:

|\
| * ^[[33m97997cf ^[[31m6 days ago ^[[34mTimothy Stephens <[email protected]> ^[[32m ^[[mbugzid:16451 new lockfile
* | ^[[33m4245715 ^[[31m6 days ago ^[[34mTimothy Stephens <[email protected]> ^[[32m ^[[mbugzid:16451 added tag script v1, new lockfile
|/
* ^[[33m98cc3a6 ^[[31m6 days ago ^[[34mTimothy Stephens <[email protected]> ^[[32m ^[[mbugzid:16451 include .lock for deploy, temporarily remov$
* ^[[33meaa8b2f ^[[31m6 days ago ^[[34mTimothy Stephens <[email protected]> ^[[32m ^[[mbugzid:16451 removed submodulegit status
* ^[[33m3b6c82f ^[[31m6 days ago ^[[34mTimothy Stephens <[email protected]> ^[[32m ^[[mbugzid:16451 merge master 2014-11-13
1

There are 1 best solutions below

0
On

These are escape characters to show colors in the console: http://misc.flogisoft.com/bash/tip_colors_and_formatting.

You should have git-log not display colors when you are redirecting output to CHANGELOG.md