chore: 加 .gitattributes 统一 Java/SQL/shell 等文本文件行尾为 LF

仓库历史存在零星 CRLF 文件(Windows 编辑器保存导致),每次他人修改都会出现
整文件 diff 污染 git blame。显式规则让 git add 自动规范化,避免复现。

*.bat/*.cmd/*.ps1 保留 CRLF(Windows 原生脚本语义要求),二进制类型显式 binary
阻止任何转换。

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
lzh
2026-04-24 13:31:32 +08:00
parent 5756f23ed7
commit ca575d6297

49
.gitattributes vendored Normal file
View File

@@ -0,0 +1,49 @@
# 统一文本文件行尾为 LF避免 Windows 编辑器把 LF 变 CRLF 污染 diff / git blame
* text=auto eol=lf
# 源码类:显式标记,拒绝 autocrlf
*.java text eol=lf
*.kt text eol=lf
*.groovy text eol=lf
*.xml text eol=lf
*.yaml text eol=lf
*.yml text eol=lf
*.json text eol=lf
*.properties text eol=lf
*.md text eol=lf
*.sql text eol=lf
*.sh text eol=lf
*.py text eol=lf
*.ts text eol=lf
*.tsx text eol=lf
*.js text eol=lf
*.vue text eol=lf
*.html text eol=lf
*.css text eol=lf
*.scss text eol=lf
Jenkinsfile text eol=lf
Dockerfile text eol=lf
# Windows 专用脚本保持 CRLF
*.bat text eol=crlf
*.cmd text eol=crlf
*.ps1 text eol=crlf
# 二进制类:禁止任何转换
*.jar binary
*.class binary
*.png binary
*.jpg binary
*.jpeg binary
*.gif binary
*.ico binary
*.pdf binary
*.zip binary
*.gz binary
*.so binary
*.dll binary
*.exe binary
*.woff binary
*.woff2 binary
*.ttf binary
*.eot binary