Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

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.

I tried adding this line to .gitattributes:

*.png binary

But the files, although correct in the working directory, still show up as unchanged and git add does nothing.

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?

like image 513
Fabian Schmengler Avatar asked Feb 18 '15 11:02

Fabian Schmengler


1 Answers

I managed to solve it myself while writing down the question:

  1. Remove all PNG files from repository but keep the working copies:

    git rm --cached **/*.png
    
  2. Add them again

    git add **/*.png
    
  3. Ready to commit!

like image 151
Fabian Schmengler Avatar answered Oct 20 '22 19:10

Fabian Schmengler