Git Log> CHANGELOG.md产生奇怪的字符

时间:2014-11-19 21:10:50

标签: git git-log

我使用以下命令在提交之前立即生成CHANGELOG.md:

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

当我直接运行命令时,不是&gt; CHANGELOG.md,我得到了预期的漂亮输出:

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

但在CHANGLOG.md中,我收到了奇怪的^[[34m字符:

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

1 个答案:

答案 0 :(得分:0)

这些是在控制台中显示颜色的转义字符:http://misc.flogisoft.com/bash/tip_colors_and_formatting

将输出重定向到CHANGELOG.md时,git-log不应显示颜色