'git diff -b --color is ignoring entire files that have more than space changes
Note: I think i already answered this, scroll down..
Using git version 2.25.1
Im trying to figure out why, my alias alias gd="git diff -b --color" when i run gd its missing entire files.
Example:
Running gd is missing this file (ansible/client_plays/ssl.yml) altogether, then when i run git diff it shows it
--- a/ansible/client_plays/ssl.yml
+++ b/ansible/client_plays/ssl.yml
@@ -79,4 +79,4 @@ all:
10.0.1.211:
nomad-jobs:
- 10.0.1.211:
\ No newline at end of file
+ 10.0.1.211:
Is there some reason the -b would be ignoring those changes? (full omission of ip address, thats major, not just space) Is there some reason --color may be ignoring those changes?
Edit: Gosh i think im misreading this also. I see it says no new line at the end of the file. I realize that s my clue. But I was thinking it was saying the IP was omitted, but looks like it is saying it was put back.
Can i trust this alias in the future? I just lost my trust in it for a minute there, but looks like im good actually.
I'll gather the other example file i had, lets check that one too...
+++ b/ansible/playbook.yml
@@ -119,4 +119,4 @@
- hosts: kibana-dashboard
tasks:
- import_role:
- name: kibana-dashboard
\ No newline at end of file
+ name: kibana-dashboard
Ok I think ive just had a long day already. Can someone comment that either im going insane, this looks good and my alias is working as expected? I think it is now, just asking... Thanks.
Solution 1:[1]
This is indeed a confusing diff, but it is actually only a whitespace change. The preimage (the old code) contains an identical line to the image (the new code), but without the trailing newline.
This syntax is practically required because you have to an addition and a deletion in the diff so you can place the \ No newline at end of file marker after the proper line. For example, if that marker were after the + line, then it would mean that the newline was deleted, not added.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | bk2204 |
