简体   繁体   English

二进制文件在git checkout后显示为已修改

[英]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.

相关问题 git checkout错误:无法创建文件 - git checkout error: unable to create file git - 如何不签出文件或文件夹 - git - How to Don't checkout a file or folder 打开文件后检查文件是否在关闭时被修改 - after opening a file check if the file was modified on close 修改任何文件后自动传输到ftp - Automatic transfer to ftp after any file is modified 通过批处理文件在GIT中创建已修改文件的存档 - Create archive of modified files in GIT via batch file Git认为每个文件都是由于时间戳差异而修改的-如何解决? - Git thinks every file modified because of timestamp difference — how to fix? 为什么 git 在差异视图中没有更改时显示文件已修改? - Why does git show a file is modified when there are no changes in the diff view? Git不会还原或提交它认为已修改的文件 - Git won't revert or commit a file that it thinks is modified 如何更改git status的行为,显示最终未提交的已修改文件? - How to change the behavior of git status showing modified files which are eventually not committed? 从Windows复制了一堆文件到ubuntu服务器,现在所有文件都显示为git,带有^ M - Copied a bunch of files from windows to ubuntu server and now all the files are showing modified in git with ^M
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM