crlf-normalization
worktree
repo with .gitattributes enforcing LF line endings on all text files (text=auto eol=lf)
Description
A root `.gitattributes` rule (`* text=auto eol=lf`) tells Git to
normalise all text files to LF on commit and to write LF to the
working tree on checkout — overriding platform defaults.
The committed text file (`src/lf-only.txt`) is stored with LF endings
in the git object store regardless of the host OS.
Platform notes:
- Windows (core.autocrlf=true by default): without `.gitattributes`
Git would store LF but write CRLF on checkout. The `eol=lf`
attribute overrides that, keeping LF in the working tree.
- macOS / Linux (LF by default): the rule is a no-op for checkout
but still normalises any stray CRLF to LF on commit.
- Git emits "CRLF will be replaced by LF" when staging a file with
Windows-style endings under this rule — useful for testing
warning-suppression or line-ending conversion UI.
Useful for testing:
- `.gitattributes` rule parsing (`text=auto`, `eol=lf`)
- Line-ending normalisation detection in diff and blame views
- "mixed line endings" or CRLF-conversion warnings in commit composers Contracts
- main is checked out
- main has 2 commits
- .gitattributes contains "* text=auto eol=lf"
- src/lf-only.txt is committed with LF-only line endings
- worktree is clean
Tags
Branches
main Use it
import { spinUpScenario } from '@gfargo/git-scenarios'
const repo = await spinUpScenario('crlf-normalization') npx git-scenarios create crlf-normalization import { describeWithScenario } from '@gfargo/git-scenarios/jest'
describeWithScenario('crlf-normalization', (getRepo) => {
it('should have the expected state', async () => {
const repo = getRepo()
// your assertions here
})
}) Commit graph
* 9afdcd6 (HEAD -> main) chore: enforce LF line endings via .gitattributes
* 7520170 chore: initial