![](/img/trans.png)
[英]GIT bash not recognizing changes to “.classpath” file via “git diff”
[英]Why does git show a file is modified when there are no changes in the diff view?
我正在將 git 與 VS 2019 一起使用,並且我經常遇到 git 顯示文件正在修改但當我與之前的比較時,差異視圖顯示沒有變化的情況。
當我單擊“撤消更改”時,沒有任何反應,文件保留在修改后的 state 中。 我想也許該文件正在被自動編輯,所以我嘗試在撤消更改之前關閉文檔的 window ,但這也不起作用。 我還懷疑這可能與 eol 更改有關,但我在 VS 中確認行尾是 CRLF 並且與我的 gitattributes 匹配。
*.csproj text eol=crlf
*.sln text eol=crlf
*.cs text eol=crlf
*.json text eol=crlf
*.config text eol=crlf
*.xml text eol=crlf
[core]
autocrlf true
在這些情況下,我唯一能做的就是無論如何提交更改,這會用未修改的文件破壞歷史記錄,或者吹走 repo 並重新克隆它。 硬重置也無濟於事。
您的文件可能已經暫存,並准備好提交。
在這種情況下,查看這些文件中差異的最簡單方法是使用“--cached”選項,如下所示:
git diff --cached
或者
git diff --cached <file_name>
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.