Enforce LF line endings everywhere
This is a principle
A reusable technical claim: something I would want true in any of my work.
Claim. Normalise all text files to LF line endings, and enforce it in more
than one place - .gitattributes, .editorconfig, and a commit-time hook -
rather than trusting each contributor's editor.
Why. Mixed CRLF/LF endings produce noisy diffs, break shell scripts and
heredocs, and cause spurious "whole file changed" churn when a Windows editor
rewrites a file. Declaring LF once at the repository level makes the outcome
independent of who checks out the repo on which OS. Layering the three
mechanisms covers different moments: .gitattributes at checkout/commit,
.editorconfig while typing, the hook as a backstop.
Snippet.
* text eol=lf
# .editorconfig
[*]
end_of_line = lf
# .pre-commit-config.yaml
- id: mixed-line-ending
args: [--fix=lf]
How enforced. Belt-and-braces: Git normalises on checkout, EditorConfig-aware
editors normalise on save, and mixed-line-ending fixes anything that slips
through. An instance of Mirror every local guard in CI applied to whitespace.
BacklinksΒΆ
The following pages link to this page: