diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..1cb0a30 --- /dev/null +++ b/.gitattributes @@ -0,0 +1,44 @@ +# 统一换行符,避免 Windows 和 WSL 之间来回切导致的假改动。 +# +# 现象:文件内容一个字没改,git diff 却显示整行整行地变, +# review 时看不出真正改了什么。根因是同一个文件在两个环境里 +# 被存成了 CRLF 和 LF 两种版本。 +# +# 配置生效后需要在**干净的工作区**上跑一次: +# git add --renormalize . +# git commit -m "chore: 统一换行符" +# 干净的意思是先把手上没提交的改动提交掉,否则会和真实改动混在一起。 + +# 默认:由 git 自动判断是不是文本;是文本就在仓库里统一存成 LF +* text=auto eol=lf + +# 这两类是 Windows 脚本,必须 CRLF,否则可能执行异常 +*.bat text eol=crlf +*.cmd text eol=crlf +*.ps1 text eol=crlf + +# 源码和文档,明确按 LF +*.py text eol=lf +*.go text eol=lf +*.md text eol=lf +*.txt text eol=lf +*.mod text eol=lf +*.sum text eol=lf +*.html text eol=lf +*.css text eol=lf +*.js text eol=lf +*.sql text eol=lf + +# 安卓控件树导出,是文本 +*.xml text eol=lf + +# 二进制:绝不能做换行符转换,否则文件会损坏 +*.xlsx binary +*.xls binary +*.png binary +*.jpg binary +*.jpeg binary +*.gif binary +*.ico binary +*.exe binary +*.db binary