Can git be configured to not perform autocrlf on certain files?

倖福魔咒の 提交于 2021-01-27 07:29:43

问题


I am using git on a Java project which is deployed to Windows, Linux, and Mac clients. For this Java project, I also maintain *.sh scripts for running the compiled binaries on Mac/Linux and .exe/.bat files for running the compiled binaries on Windows. My development environment is Windows.

Git's autocrlf feature is converting line terminators in my *.sh scripts to the Windows format, which renders them useless on Linux/Mac after deployment. I want to save them in the Unix format and have git leave the line terminators alone. Can git be configured to ignore autocrlf for these specific files (there are three in a single folder)? If so, how?


回答1:


Looks like this is configurable if you add a .gitattributes file to the base-level folder in your repository, then explicitly call out which file types are binary, which are text, and of the text types, which should be CRLF, LF, or auto configured.

https://help.github.com/articles/dealing-with-line-endings/



来源:https://stackoverflow.com/questions/28224273/can-git-be-configured-to-not-perform-autocrlf-on-certain-files

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!