简体   繁体   中英

git log --pretty to file with error

I do it:

git log --all --format=format:'%C(bold blue)%h%C(reset) - %an%C(reset)%C(bold yellow)%d%C(reset) - %C(bold green)(%ad)%C(reset) %C(white)%s%C(reset) %C(bold white)'

Right result:

2c6f8b9 - Matheus - (Thu Sep 20 14:06:51 2012) ++ import clientes, ++ now send email ok! 
102c911 - LIVE - (Thu Sep 20 13:25:24 2012) ++ db 
93bf163 - Matheus - (Wed Sep 19 17:31:18 2012) ++ import clientes 
8539cf4 - Matheus - (Wed Sep 19 16:41:56 2012) ++ import clientes, ++ now with defaultBilling and defaultShipping 
843509a - Matheus - (Wed Sep 19 16:36:19 2012) ++ import clientes, ++ now with defaultBilling and defaultShipping 
b8de06d - Matheus - (Wed Sep 19 15:48:05 2012) ++ import clients

To my a file:

git log --all --format=format:'%C(bold blue)%h%C(reset) - %an%C(reset)%C(bold yellow)%d%C(reset) - %C(bold green)(%ad)%C(reset) %C(white)%s%C(reset) %C(bold white)' > file

Wrong result when a save in file output:

[1;34ma36b984[m - LIVE[m[1;33m[m - [1;32m(Thu Sep 20 16:16:57 2012 -0300)[m [37m++ import clientes, ok!![m [1;37m
[1;34m1794d80[m - Matheus[m[1;33m[m - [1;32m(Thu Sep 20 15:31:28 2012 -0300)[m [37mMerge remote-tracking branch 'live/master' into import-clientes[m [1;37m
[1;34me8a1735[m - LIVE[m[1;33m[m - [1;32m(Thu Sep 20 15:23:00 2012 -0300)[m [37m++ db[m [1;37m
[1;34m7c838ef[m - Matheus[m[1;33m[m - [1;32m(Thu Sep 20 15:00:52 2012 -0300)[m [37m++ import-clientes, external file[m [1;37m
[1;34m2c6f8b9[m - Matheus[m[1;33m[m - [1;32m(Thu Sep 20 14:06:51 2012 -0300)[m [37m++ import clientes, ++ now send email ok![m [1;37m
[1;34m102c911[m - LIVE[m[1;33m[m - [1;32m(Thu Sep 20 13:25:24 2012 -0300)[m [37m++ db[m [1;37m
[1;34m93bf163[m - Matheus[m[1;33m[m - [1;32m(Wed Sep 19 17:31:18 2012 -0300)[m [37m++ import clientes[m [1;37m

I try without pretty format, work perfectly. Later I try with pretty format, don't work!

How i can save this in a file, with a pretty format?

Thanks.

The output stored in your file is exactly what you've asked git for.

The first line, [1;34ma36b984[m , Maps to the color code to output blue in your shell ( [1;43m ), then your short commit hash ( a36b984 ), then a color reset.

If you want the file to be readable on its own, omit the color codes. Alternatively, cat the file, and your shell should colorize the output.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM