Issue #8823 resolved

Corrupt Images when committing from Windows

Didik Wicaksono
created an issue

https://bitbucket.org/dapurmasak/tempe/commits/acbc1d3777d78a1d6a4c251e8695d0afed99baee

Our team is using private git from bitbucket. From the beginning, commits and image assets was generated from Mac and Linux. Some team member is using Windows, and the trouble began when they try to do commit and push.

Each time we push commit to Bitbucket with image asset created from GIMP in Windows, each image become corrupted. You can see the attachment below.

And then we tried to clone it again to try and see whether the corrupted images is carried out. Unfortunately, all our images is now corrupted.

Additional info, we are using Vagrant with VIrtualBox for devops. The OS is using Ubuntu in Windows 8 host.

Our repository folder is synced to it, that's why we can do commit from Windows.

This problem also arise when we checkout to other branch in Windows.

In my opinion, this is related to LF and CRLF line endings. Any suggestion?

Comments (7)

  1. Didik Wicaksono reporter

    Finally, I have found the solution from here: http://stackoverflow.com/questions/9976986/force-lf-eol-in-git-repo-and-working-copy

    For working with Windows with Linux VirtualBox, make sure to create .gitattributes for proper handling between text files with binary files.

    Mine is:

    * text=auto
    *.css text
    *.php text
    *.js text
    *.json text
    *.txt text
    *.scss text
    *.jpg binary
    *.png binary
    *.gif binary
    

    Commit the new .gitattributes in order to apply change.

    To fix the images:

    • Delete old images,
    • Replace with correct one,
    • Run git checkout-index --force to remove cached index
    • Create another commit

    I hope it helps.

  2. Nick F

    Just to add a footnote to the above solution: I had a similar problem, caused by my having changed .gitattributes to * text eol=lf in a misguided attempt to force unix line-endings on Windows. This seemed to work fine on Windows machines, but caused images to get corrupted when committed from OS X machines. Setting .gitattributes to * text=auto was all that was needed to fix the problem so that images could be committed without problems on both Windows and OS X.

  3. Log in to comment