Da Anonimo (non verificato) , 29 Aprile 2026

Il problema dei fini riga

Windows usa CRLF, Linux e macOS usano LF.

Il setup semplice e robusto

# .gitattributes
* text=auto eol=lf

*.{cmd,bat,ps1} text eol=crlf

*.png binary
*.jpg binary
*.pdf binary
*.zip binary

Come funziona text=auto

Al commit, Git guarda i contenuti del file e normalizza i file di testo apparenti a LF.

Rinormalizzare repo esistenti

git add --renormalize .
git commit -m "Normalize line endings"

core.autocrlf versus .gitattributes

.gitattributes vince. La config per utente invita all'incoerenza.

Marcare i binari

*.png binary
*.jpg binary
*.gif binary
*.ico binary
*.pdf binary
*.zip binary
*.tar binary
*.gz binary
*.dll binary
*.exe binary

Override per file

Makefile     text eol=lf
*.sh         text eol=lf
*.bat        text eol=crlf
*.ps1        text eol=crlf
*.csv        text

Driver diff e merge

*.docx diff=docx
*.pdf diff=pdf
composer.lock merge=ours

Verificare

git check-attr -a path/to/file
git ls-files --eol