I use VSCode for editing files both on my local drive and on a shared drive. However, I've noticed that VSCode frequently does not visualize the diffs for files on the shared drive. Is this a known issue? How can I troubleshoot this?
I've tried restarting VSCode, and the Git built-in to no avail.
Let me know if there's any environment or system specifications I can share here to shed more light.
The solution was to use
git config --global core.autocrlf true. This is a possible duplicate of this post.I'm answering my own question starting with a correction. I thought was VSCode not visualizing differences because I saw files in the source control tab, with the "M" tag, but didn't see any
diffhighlighting (e.g., green, or red). But in reality VSCode was not wrong, because the diff was just one character,^M. I realized this when I didgit diff HEAD:filea fileaand noticed the entire file was red (-) and again in green (+). The difference between the original and new versions was that each line was appended with a^Mcharacter.According to this Unix.SE post the
^Mcharacter appears when files originating from Windows systems are read by Unix-like systems. My files are originating from a shared drive, which may or may not be Windows-based.I troubleshooted by situation further by using
git diff HEAD:fileb fileb, wherefilebis a file I had modified, and again the entire original file was in red (-) and the new version was in green (+), including the^Mcharacters. When I rangit diff --ignore-cr-at-eol HEAD:fileb filebit showed the correct highlighting, with only the deleted parts in red (-) and the added parts in green (+).Although this fixed everything on the command life for
git, VSCode was still tracking the files as modified. However, when I rangit config --global core.autocrlf true, then all the files that were being tracked just for the^Mcharacters were removed from the version control tab. Note, however, that before changing gitconfigI tried to fix the files manually by changing the EOL on VSCode from "CRLF" to "LF", and this change was reflected on thegitcommand line but not VSCode. Only changing Git'sconfigfixed the issue on the command line and on VSCode.