Fixing image corruption in Git

You may find that all the images you commit to a git repo are corrupting. This is especially true if you are using Windows and then pushing to a Linux origin.

One possible fix is to ensure the images are being treated as binary files. Of course everything is a binary file when it comes down to it, but this differentiates it from text. To do this, add the following lines to a .gitattributes file in the root of the repo.

*.jpg binary
*.png binary
*.gif binary

If you have images in there already, you will probably need to remove them and then re-commit them.

Timeline

Newsletter

Don't have time to check my blog? Get a weekly email with all the new posts. This is my personal blog, so obviously it is 100% spam free.

Metadata

Tags: , ,

This entry was posted on Tuesday, August 4th, 2015 at 9:37 pm and is filed under Programming, Tech. You can follow any responses to this entry through the RSS 2.0 feed. Both comments and pings are currently closed.