[英]Binary file showing as modified after git checkout
For some reason, after cloning a repository and changing branch I had one jar
file marked as modified (without being modified) and I can't seem to un-modify the file (which prevents merging branches. 出于某种原因,在克隆存储库并更改分支之后,我将一个
jar
文件标记为已修改(未经修改),而我似乎无法取消修改该文件(这会阻止合并分支)。
PS D:\src\expm> git status
On branch epic-my-wallet
Your branch is up-to-date with 'origin/feature-01'.
Changes not staged for commit:
(use "git add <file>..." to update what will be committed)
(use "git checkout -- <file>..." to discard changes in working directory)
modified: Test/Selenium/selenese-runner.jar
no changes added to commit (use "git add" and/or "git commit -a")
I tried to undo with the checkout command 我尝试使用checkout命令撤消
PS D:\src\expm> git checkout -- .
git status
output the same exact message as previously. git status
输出与以前完全相同的消息。
I tried to reset it from HEAD
with 我尝试使用
HEAD
将其重置
PS D:\src\expm> git checkout -f HEAD
Your branch is up-to-date with 'origin/feature-01'.
Please note that jar files are flagged as handled by LFS in the .gitattributes
file 请注意,
.gitattributes
文件.gitattributes
jar文件标记为由LFS处理
*.jar filter=lfs diff=lfs merge=lfs -text
Not quite sure on the next step here. 不确定此处是否要进行下一步。 The file has not been modified since its commit months ago.
自几个月前提交以来,该文件尚未修改。
edit 编辑
I should add that today we tried to reset the cache with git rm . -r --cached
我应该补充一点,今天我们尝试使用
git rm . -r --cached
重置缓存git rm . -r --cached
git rm . -r --cached
and removed the LFS cache as well (physically remove the .git/lfs
folder) and re-download the files with git reset --hard
. git rm . -r --cached
并删除LFS缓存(物理上删除.git/lfs
文件夹),然后使用git reset --hard
重新下载文件。
Due to your git setting to handle end of line, which should be to 'autocrlf', git modify/corrupt the jar file at checkout! 由于您的git设置要处理行尾,应该为'autocrlf',因此git在结帐时修改/损坏jar文件!
You should add a '.gitattributes' file in your repository where you set the 'jar' files as 'binary' and git will no more try to convert end of lines. 您应该在存储库中添加“ .gitattributes”文件,在其中将“ jar”文件设置为“ binary”,而git将不再尝试转换行尾。
That's the recommended way to handle end of line in a git repository to solve such problems... 这是处理git存储库中的行尾以解决此类问题的推荐方法...
It seem the problem was linked to Git LFS in some way. 看来问题与Git LFS有某种联系。 We upgraded both Git (from 2.8.4 to the current at 2.9.3) and Git LFS (from 1.2.1 locally to the latest 1.3.1 at the moment).
我们将Git(从2.8.4升级到当前的2.9.3)和Git LFS(从1.2.1本地升级到了最新的1.3.1)都进行了升级。 Then deleted and re-added the jar file.
然后删除并重新添加jar文件。
We did a clean clone on a new folder after that and the problem seemed to be resolved. 之后,我们在新文件夹上进行了干净的克隆,问题似乎已解决。 Could be the upgrade of git + lfs that resolved the issue.
可能是git + lfs的升级解决了该问题。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.