I'm trying to figure out why GIT does not apply reverse patch on javascript and ruby files, but does it on php files. My steps are:
...modifying some php, ruby and js files...
git stash
#saving changes into stash
git stash apply
#applying them
git stash show -p | git apply -R
#reverse patching
it works fine and does un-apply my stashed changes, but only for php files, not for ruby or javascript. All files (even php) has CRLF
line endings. When I tried files with LF
line endings, no issues were at all, but I'm still wondering, why it does work only for particular file types in case of CRLF
lines.
Thanks for your help!
I've found the issue and I think my solution would be usefull for others. Actually, it was happening after initinal migration from Subversion to Git. The issue was that files in project had different line endings, so it is not depends on filetype. When Git was trying to convert them all to one format during checkout, it was not correct and in some cases CRLF
was broken. Solution I found:
git config --global core.autocrlf input
# Set this setting on OSX or Linux
git config --global core.autocrlf true
# Set this setting on Windows
git rm --cached -r .
git add .
git commit -m "Line endings fix. Now all lines are in LF format"
git reset --hard
After that I have a clean branch with all files in one format. Hope, this will help someone.