git push后图像损坏 [英] Images corrupt after git push

查看:365
本文介绍了git push后图像损坏的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在git repo中添加了一些.png图像,然后将它们推送到我的远程存储库中.我注意到图像位于远程存储库中,但是它们已损坏.

I added some .png images to my git repo and then pushed them to my remote repository. I noticed that the images are in the remote repository, but they are broken.

为了验证这一点,我比较了本地和远程存储库中图像的二进制数据.我还在两个存储库中的图像上都运行了file命令.

In order to verify this, I compared the binary data for the images on my local and my remote repos. I also ran the file command on images in both repos.

二进制数据的前10行:

First 10 Lines of Binary data:

8950 4e47 0d0a 1a0a 0000 000d 4948 4452 0000 0019 0000 0014 0806 0000 0078 7796 bd00 0000 1974 4558 7453 6f66 7477 6172 6500 4164 6f62 6520 496d 6167 6552 6561 6479 71c9 653c 0000 0373 6954 5874 584d 4c3a 636f 6d2e 6164 6f62 652e 786d 7000 0000 0000 3c3f 7870 6163 6b65 7420 6265 6769 6e3d 22ef bbbf 2220 6964 3d22 5735 4d30 4d70 4365 6869 487a 7265 537a 4e54 637a 6b63 3964 223f 3e20 3c78 3a78 6d70

8950 4e47 0d0a 1a0a 0000 000d 4948 4452 0000 0019 0000 0014 0806 0000 0078 7796 bd00 0000 1974 4558 7453 6f66 7477 6172 6500 4164 6f62 6520 496d 6167 6552 6561 6479 71c9 653c 0000 0373 6954 5874 584d 4c3a 636f 6d2e 6164 6f62 652e 786d 7000 0000 0000 3c3f 7870 6163 6b65 7420 6265 6769 6e3d 22ef bbbf 2220 6964 3d22 5735 4d30 4d70 4365 6869 487a 7265 537a 4e54 637a 6b63 3964 223f 3e20 3c78 3a78 6d70

file命令的结果:

bundles/admin/public/images/messages-icon.png:PNG图像数据,24 x 16,8位/彩色RGBA,非隔行扫描

bundles/admin/public/images/messages-icon.png: PNG image data, 24 x 16, 8-bit/color RGBA, non-interlaced

图片已推送到远程存储库

二进制数据的前10行:

Image pushed to remote repository

First 10 Lines of Binary data:

8950 4e47 0a1a 0a00 0000 0d49 4844 5200 0000 1900 0000 1408 0600 0000 7877 96BD 0000 0019 7445 5874 536f 6674 7761 7265 0041 646f 6265 2049 6d61 6765 5265 6164 7971 c965 3c00 0003 7369 5458 7458 4d4c 3a63 6f6d 2e61 646f 6265 2e78 6d70 0000 0000 003c 3f78 7061 636b 6574 2062 6567 696e 3d22 efbb bf22 2069 643d 2257 354d 304d 7043 6568 6948 7a72 6553 7a4e 5463 7a6b 6339 6422 3f3e 203c 783a 786d 706d

8950 4e47 0a1a 0a00 0000 0d49 4844 5200 0000 1900 0000 1408 0600 0000 7877 96bd 0000 0019 7445 5874 536f 6674 7761 7265 0041 646f 6265 2049 6d61 6765 5265 6164 7971 c965 3c00 0003 7369 5458 7458 4d4c 3a63 6f6d 2e61 646f 6265 2e78 6d70 0000 0000 003c 3f78 7061 636b 6574 2062 6567 696e 3d22 efbb bf22 2069 643d 2257 354d 304d 7043 6568 6948 7a72 6553 7a4e 5463 7a6b 6339 6422 3f3e 203c 783a 786d 706d

file命令的结果:

bundles/admin/public/images/notifications-icon.png:数据

bundles/admin/public/images/notifications-icon.png: data

为什么会这样?我在整个Google和该网站上搜索了答案,但没有找到答案.

Why would this be happening? I searched all over google and this site for answers but have found none.

推荐答案

我也遇到了这个问题-这是一个通用的.gitattributes,对于为我工作的php web存储库来说,通常看起来是安全的:https://github.com/Danimoth/gitattributes/blob/master/Web.gitattributes

I had this issue too - here's a generic .gitattributes that looks generally safe for php web repos that worked for me: https://github.com/Danimoth/gitattributes/blob/master/Web.gitattributes

在添加新的gitattributes之前和之后运行git check-attr --all-path/to/png显示该图像文件最初被视为文本文件,现在是二进制文件(请注意,我必须提交/推送) .gitattributes文件使其在远程上生效

running git check-attr --all -- path/to/png before and after adding the new gitattributes showed that the image file was originally treated as a text file, and now it's binary (note I had to commit/push the .gitattributes file for it to take effect on remote)

万一链接失效:

# These settings are for any web project

# Handle line endings automatically for files detected as text
# and leave all files detected as binary untouched.
# * text=auto
# NOTE - originally I had the above line un-commented.  it caused me a lot of grief related to line endings because I was dealing with WordPress plugins and the website changing line endings out if a user modified a plugin through the web interface.  commenting this line out seems to have alleviated the git chaos where simply switching to a branch caused it to believe 500 files were modified.

#
# The above will handle all files NOT found below
#

#
## These files are text and should be normalized (Convert crlf => lf)
#

# source code
*.php text
*.css text
*.sass text
*.scss text
*.less text
*.styl text
*.js text
*.coffee text
*.json text
*.htm text
*.html text
*.xml text
*.svg text
*.txt text
*.ini text
*.inc text
*.pl text
*.rb text
*.py text
*.scm text
*.sql text
*.sh text
*.bat text

# templates
*.ejs text
*.hbt text
*.jade text
*.haml text
*.hbs text
*.dot text
*.tmpl text
*.phtml text

# server config
.htaccess text

# git config
.gitattributes text
.gitignore text
.gitconfig text

# code analysis config
.jshintrc text
.jscsrc text
.jshintignore text
.csslintrc text

# misc config
*.yaml text
*.yml text
.editorconfig text

# build config
*.npmignore text
*.bowerrc text

# Heroku
Procfile text
.slugignore text

# Documentation
*.md text
LICENSE text
AUTHORS text


#
## These files are binary and should be left untouched
#

# (binary is a macro for -text -diff)
*.png binary
*.jpg binary
*.jpeg binary
*.gif binary
*.ico binary
*.mov binary
*.mp4 binary
*.mp3 binary
*.flv binary
*.fla binary
*.swf binary
*.gz binary
*.zip binary
*.7z binary
*.ttf binary
*.eot binary
*.woff binary
*.pyc binary
*.pdf binary

这篇关于git push后图像损坏的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆