When i do a git status i get below image file is changed. However its only image file and should not have any LF/CRLF in the file,
$ git status
# HEAD detached at origin/master
# Changes not staged for commit:
# (use "git add <file>..." to update what will be committed)
# (use "git checkout -- <file>..." to discard changes in working directory)
#
# modified: public/css/chosen-sprite.png
When i type git diff to see the changes i got.
$ git diff public/css/chosen-sprite.png
warning: CRLF will be replaced by LF in public/css/chosen-sprite.png.
The file will have its original line endings in your working directory.
diff --git a/public/css/chosen-sprite.png b/public/css/chosen-sprite.png
index c57da70..0476a8f 100644
Binary files a/public/css/chosen-sprite.png and b/public/css/chosen-sprite.png differ
So what i did was i tried to checkout the file to make sure its same as the remote origin file. So i did below
$git checkout public/css/chosen-sprite.png
But didn't make any changes above file or git status, still shows as it changed. Any idea on how to fix this issue?
CodePudding user response:
By default, git treats all files as text, and converts line endings when you are using it on a machine with non-LF line endings, such as windows. If you want it to treat a file as binary (and not convert the line endings) you must identify it as such in the .gitattributes file. Something like
*.png binary
should do the trick.