问题
After update to 1.19.1 I'm getting this error constantly. The content on disk is newer. Click on Compare to compare your version with the one on disk.
回答1:
VS Code will show you an error message when you try to save a file that cannot be saved because it has changed on disk. VS Code blocks saving the file to prevent overwriting changes that have been made outside of the editor.
In order to resolve this issue, click the Compare
action in the error message to open a diff editor that will show you the contents of the file on disk (to the left) compared to the contents in VS Code (on the right): {Refer an Image}
You must either accept the changes or revert the changes. Without taking any of the mentioned actions, you cant save the file.
P.S Above answer has been referred from visual studio code official documentation.
you can read detailed information about this topic: [https://code.visualstudio.com/docs/getstarted/tips-and-tricks#_preventing-dirty-writes][2]
回答2:
Here is another way:
- Copy the full content of your dirty file let say abc.js to somewhere in notepad
- Delete the file: rm abc.js
- Get the file from the repository(my case its Git): git checkout abc.js
- Paste the previously copied content or paste the updated content back and save.
Hope you won't see this issue.
回答3:
Close all editors, when you switch the branch in GIT, then it wouldn't appear
回答4:
Click on the compare button, two screens (left and right) will be displayed, click on the tick mark which appears on the right-hand side(in my case). That's it, it will be saved.
来源:https://stackoverflow.com/questions/47892646/the-content-on-disk-is-newer-click-on-compare-to-compare-your-version-with-the