问题描述
我在Java项目上使用git,该项目已部署到Windows,Linux和Mac客户端.对于此Java项目,我还维护用于在Mac/Linux上运行已编译二进制文件的* .sh脚本和用于在Windows上运行已编译二进制文件的 .exe/ .bat文件.我的开发环境是Windows.
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的autocrlf功能将我的* .sh脚本中的行终止符转换为Windows格式,这使它们在部署后在Linux/Mac上无用.我想将它们保存为Unix格式,并让git单独保留行终止符.可以将git配置为忽略这些特定文件的autocrlf(单个文件夹中有三个文件)吗?如果可以,怎么办?
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?
推荐答案
如果将 .gitattributes
文件添加到存储库中的基本级别文件夹,然后显式调出,则看起来可配置哪些文件类型是二进制文件,哪些是文本文件,哪些文本类型应该是CRLF,LF或自动配置.
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-ends/
这篇关于可以将git配置为不对某些文件执行autocrlf吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!