Git 将未修改的文件显示为已修改
Git shows unmodified files as modified
设置
- git 版本 2.32.0.windows.1
- TortoiseGit 2.13.0.1
- git 配置-l
- 差异工具:BeyondCompare
http.sslcainfo=C:/Program Files/Git/mingw64/ssl/certs/ca-bundle.crt
http.sslbackend=openssl
diff.astextplain.textconv=astextplain
filter.lfs.clean=git-lfs clean -- %f
filter.lfs.smudge=git-lfs smudge -- %f
filter.lfs.process=git-lfs filter-process
filter.lfs.required=true
credential.helper=manager-core
core.autocrlf=true
core.fscache=true
core.symlinks=false
core.editor="C:\Program Files (x86)\Notepad++\notepad++.exe" -multiInst -notabbar -nosession -noPlugin
pull.rebase=false
credential.https://dev.azure.com.usehttppath=true
init.defaultbranch=master
user.email=***
user.name=***
core.quotepath=false
core.commitgraph=true
core.longpaths=true
receive.advertisepushoptions=true
gc.writecommitgraph=true
credential.helper=manager-core
filter.lfs.process=git-lfs filter-process
filter.lfs.required=true
filter.lfs.clean=git-lfs clean -- %f
filter.lfs.smudge=git-lfs smudge -- %f
submodul.recurse=true
core.bare=false
core.repositoryformatversion=0
core.filemode=false
core.symlinks=false
core.ignorecase=true
core.logallrefupdates=true
remote.origin.url=***
remote.origin.fetch=+refs/heads/*:refs/remotes/origin/*
branch.master.remote=origin
branch.master.merge=refs/heads/master
历史
我们从 SVN 切换到 GIT,然后我们将编码从 Windows1252 转换为 UTF8。在这一点上一切看起来都很好,但我还是想提一下。这些更改已成功提交。
错误
git status
和 TortoiseGit 都列出了很多文件(可能是全部)已修改,但这些文件是二进制相同的...
git diff
将所有行显示为已删除,将完全相同的行显示为已添加。
git diff -w
仅列出非文本文件 (jar)。
差异对我来说似乎有点奇怪,因为所有文件都完全相同(我比较了十六进制数据)。
由于所有内容都已修改,因此我无法拉取。我的同事有时也有类似的问题。
编辑:
我还注意到该错误仅在我们添加 .git 属性的提交之后发生。这包含如下内容:
*.c text diff=c
*.cpp text diff=cpp
*.hpp text diff=cpp
*.h text diff=c
如果我注释掉这些行,所有修改都将消失。如果我在修改中评论那些行,它们仍然消失了。
尝试次数
- git 重置 --hard
- git 隐藏
- 通过 TortoiseGit 还原
在这些尝试之后 git status
和 TortoiseGit 仍然将这些文件列为已修改...
如果我提交这些文件,这种奇怪的行为就会消失,但可能会重新出现在不同的分支中。
唯一改变的是文件的最后修改时间戳。时间戳更改为实际时间。
问题
为什么所有这些文件都被列为已修改?是否有我缺少的设置?
正如@torek 在评论中指出的那样:.gitattribute 文本设置导致了问题。我们提交了那些 修改后的 文件,之后一切顺利。
设置
- git 版本 2.32.0.windows.1
- TortoiseGit 2.13.0.1
- git 配置-l
- 差异工具:BeyondCompare
http.sslcainfo=C:/Program Files/Git/mingw64/ssl/certs/ca-bundle.crt
http.sslbackend=openssl
diff.astextplain.textconv=astextplain
filter.lfs.clean=git-lfs clean -- %f
filter.lfs.smudge=git-lfs smudge -- %f
filter.lfs.process=git-lfs filter-process
filter.lfs.required=true
credential.helper=manager-core
core.autocrlf=true
core.fscache=true
core.symlinks=false
core.editor="C:\Program Files (x86)\Notepad++\notepad++.exe" -multiInst -notabbar -nosession -noPlugin
pull.rebase=false
credential.https://dev.azure.com.usehttppath=true
init.defaultbranch=master
user.email=***
user.name=***
core.quotepath=false
core.commitgraph=true
core.longpaths=true
receive.advertisepushoptions=true
gc.writecommitgraph=true
credential.helper=manager-core
filter.lfs.process=git-lfs filter-process
filter.lfs.required=true
filter.lfs.clean=git-lfs clean -- %f
filter.lfs.smudge=git-lfs smudge -- %f
submodul.recurse=true
core.bare=false
core.repositoryformatversion=0
core.filemode=false
core.symlinks=false
core.ignorecase=true
core.logallrefupdates=true
remote.origin.url=***
remote.origin.fetch=+refs/heads/*:refs/remotes/origin/*
branch.master.remote=origin
branch.master.merge=refs/heads/master
历史
我们从 SVN 切换到 GIT,然后我们将编码从 Windows1252 转换为 UTF8。在这一点上一切看起来都很好,但我还是想提一下。这些更改已成功提交。
错误
git status
和 TortoiseGit 都列出了很多文件(可能是全部)已修改,但这些文件是二进制相同的...
git diff
将所有行显示为已删除,将完全相同的行显示为已添加。
git diff -w
仅列出非文本文件 (jar)。
差异对我来说似乎有点奇怪,因为所有文件都完全相同(我比较了十六进制数据)。
由于所有内容都已修改,因此我无法拉取。我的同事有时也有类似的问题。
编辑: 我还注意到该错误仅在我们添加 .git 属性的提交之后发生。这包含如下内容:
*.c text diff=c
*.cpp text diff=cpp
*.hpp text diff=cpp
*.h text diff=c
如果我注释掉这些行,所有修改都将消失。如果我在修改中评论那些行,它们仍然消失了。
尝试次数
- git 重置 --hard
- git 隐藏
- 通过 TortoiseGit 还原
在这些尝试之后 git status
和 TortoiseGit 仍然将这些文件列为已修改...
如果我提交这些文件,这种奇怪的行为就会消失,但可能会重新出现在不同的分支中。
唯一改变的是文件的最后修改时间戳。时间戳更改为实际时间。
问题
为什么所有这些文件都被列为已修改?是否有我缺少的设置?
正如@torek 在评论中指出的那样:.gitattribute 文本设置导致了问题。我们提交了那些 修改后的 文件,之后一切顺利。