Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to use git diff show some invisible characters differences?

Tags:

git

When I use git diff, I saw the differences like below:

-    self.conv_2 = nn.Conv2d(C_in, C_out // 2, 1, stride=2, padding=0, bias=False) 
+    self.conv_2 = nn.Conv2d(C_in, C_out // 2, 1, stride=2, padding=0, bias=False) 

And I'm sure there are no white backspace difference in these two lines. However, I think these two lines are totally same.

I wonder why does git think they are different?

And is there a way to let git diff show the special characters difference?

like image 788
one Avatar asked Jan 01 '23 15:01

one


1 Answers

The --ws-error-highlight flag might be useful.

git diff --ws-error-highlight=all

Alternatively, you can pipe the git diff output to cat and use its -A flag to explicitly print a variety of non-printing characters.

git diff | cat -A
like image 77
chuckx Avatar answered Jan 05 '23 08:01

chuckx