Files
TripLog/.gitattributes
T
laoyang 8e4004db85 锁定仓库换行符为 LF,避免 git archive 产出 CRLF 造成比对假象
仓库里的 blob 和线上部署的文件都是 LF,但本机 core.autocrlf=true 时
`git archive HEAD` 会把它转成 CRLF 输出。于是拿 git archive 打部署包、
或做改动前后快照比对时,会出现「所有文件都不同」的假象,白排查很久。
加 .gitattributes 锁成 LF 之后,仓库 / 检出 / archive 三者一致。

排查提示:判断行尾不要用 grep 去匹配 $'\r'(Git Bash 下这个转义会被吞成
空模式,导致每一行都命中,得出「全是 CRLF」的错误结论),要用 Python
读字节数统计 CR(b.count(13))。
2026-09-22 22:05:36 +08:00

11 lines
625 B
Plaintext
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# 仓库内一律以 LF 存储、以 LF 检出。
#
# 为什么必须锁死:线上(Linux)文件是 LF,仓库里存的也是 LF,但只要
# core.autocrlf=true,`git archive HEAD` 就会把内容转成 CRLF 输出。
# 于是「用 git archive 打的部署包 / 改动前后快照」与工作树逐字节不一致,
# 表现为「所有文件都不同」的假象,白排查半天。锁成 LF 后三者一致。
#
# 注意:判断行尾别用 `grep -c $'\r'`(Git Bash 下 $'\r' 会被吞成空模式,
# 每行都命中 → 误判「全是 CRLF」)。用 Python 数字节:b.count(13)。
* text=auto eol=lf