[英]Committed PNG files to Git on Windows broke %PNG\r\n header
I added lots of PNG files to a Git repository on Windows, unfortunately with the setting text eol=lf
to not commit Windows line breaks. 我在Windows上向Git存储库添加了大量PNG文件,遗憾的是设置
text eol=lf
不提交Windows换行符。
The problem is that the PNG header must be in the form %PNG\\r\\n
and now all PNG images are in Git with the header %PNG\\n
and cannot be displayed like that. 问题是PNG标题必须是
%PNG\\r\\n
,现在所有PNG图像都在Git中,标题为%PNG\\n
,并且无法像这样显示。
I tried adding this line to .gitattributes
: 我尝试将此行添加到
.gitattributes
:
*.png binary
But the files, although correct in the working directory, still show up as unchanged and git add
does nothing. 但是文件虽然在工作目录中是正确的,但仍然显示为未更改,
git add
不执行任何操作。
I managed to fix single files with checking out the broken version and editing it manually but I hope there is a less tedious way. 我设法修复单个文件,检查损坏的版本并手动编辑它,但我希望有一个不那么繁琐的方式。
How can I fix my repository without modifying the individual files? 如何在不修改单个文件的情况下修复存储库?
I managed to solve it myself while writing down the question: 在写下这个问题时,我设法自己解决了这个问题:
Remove all PNG files from repository but keep the working copies: 从存储库中删除所有PNG文件,但保留工作副本:
git rm --cached **/*.png
Add them again 再次添加它们
git add **/*.png
Ready to commit! 准备好了!
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.