How to suppress display of escape sequences in diff

When I run git diff to see what has been changed in the modified file, diff displays a lot of highlighted escape sequences. For instance:

ESC[1mindex a7671ab..c228e2c 100644ESC[m ESC[1m--- a/core/bp-nav-horizontal.phpESC[m ESC[1m+++ b/core/bp-nav-horizontal.phpESC[m ESC[ 36m@ @ -77,7 +77,7 @@ESC[m <!-- Contact Us -->ESC[m <ul>ESC[m <li>ESC[m 

How can I suppress these ESC[xxx characters ESC[xxx . They are very difficult to read the text.

Modified Aug 15, 2014

This is not about git diff. Git log displays also show ESC... characters. This seems like a configuration issue, but I don't know where it is. Where should I look?

+5
source share
3 answers

The problem is that the pager used by GIT to print differences and logs. Adding -R to the configuration for a less drastic problem for me. I used

 git config --global core.pager "less -R" 
+6
source

You may have set color.ui = always (or auto , and terminal detection does not work). You can disable it with never (if it always tries auto ).

You can configure all the commands using config.ui or specify for git -diff with color.diff .

 git config --global color.ui never 

Use

 git config --local -l git config --global -l git config --system -l 

List the current parameters of the project, user, and machine. For temporary on / off, you can use the argument --color=always for each command. For instance:

 git log --color=never 

See also: http://git-scm.com/book/en/Customizing-Git-Git-Configuration

+3
source

Git 2.14.x / 2.15 (Q3 2017) will finally respect git config color.ui never .

See commit 11b087a , commit 18fb7ff , commit d75dfb1 , commit d8b6868 , commit 136c8c8 , commit ab7ded3 , commit 29ef53c , commit aa8a5d1 , commit 18a2565 , commit bf285ae , commit 4a68e36 , commit 51331aa , commit 097b68168 , commit01d2ded1 ) Jeff King ( peff ) .
(merged Junio ​​C Hamano - gitster - in commit 15595ce , August 11, 2017)

" %C(color name) " in fairly printed format, ANSI color skip codes were always generated, which was an early design error.
Now they honor the configuration (for example, " color.ui = never "), as well as the tty-ness output environment.

0
source

Source: https://habr.com/ru/post/1200443/


All Articles