git推送后图像损坏?

内容来源于 Stack Overflow,并遵循CC BY-SA 3.0许可协议进行翻译与使用

  • 回答 (1)
  • 关注 (0)
  • 查看 (20)

我在gitrepo中添加了一些.png映像,然后将它们推送到远程存储库。我注意到图像在远程存储库中,但它们已经损坏。

为了验证这一点,我比较了本地和远程repos上图像的二进制数据。我还运行了file命令对两个repos中的图像进行处理。

图像上局部储存库

前10行二进制数据:

8950 4e470d0a 1a0a 0000 000d 4948 4452 0000 0000 0000 0806 0000 0806 0000 0078 bd00闭会期间6f662dbbbbbbbbbbf3c9 653c电子邮件:44d4c3a 636f 6d2e 6f62 652 e 786 d小微粉63c3f 6b65个品次6b65个品次6e3d 22ef bbbbbbbbbbbbbbbBF 3d22 4d304d70 487a。537a 4e54 637a 6B63 3964 223 f 3e20 3c78 3a78 6d70

图像推至远距离储存库

前10行二进制数据:

8950 4e47 0a1a 0a00 0000 0d49 4844 5200 0000 0000 1408 0000 0600 0000 1408 0600 0000闭会期间536 F遇事---。7a4e 5463 7a6b 6339 6422 3f3e 203 c 783 a 786 d 706 d

为什么会发生这种事?我搜索了所有的谷歌和这个网站,但没有找到答案。

提问于
用户回答回答于

在添加新的gitproperties之前和之后,运行git检查-attr-all-path/to/png显示,图像文件最初被当作文本文件处理,现在它是二进制文件(注意,我必须提交/推动.gitproperties文件才能在远程上生效)

如果链接失效:

# 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

扫码关注云+社区