.gitattributes, Line Endings & LFS
.gitattributes - per-path rules
.gitattributes (committed, unlike .gitignore's cousin config) sets rules for how Git treats specific files.
# .gitattributes
* text=auto # normalize line endings
*.sh text eol=lf # shell scripts MUST stay LF (or they break on Linux)
*.png binary # never try to diff/merge binaries
*.psd filter=lfs diff=lfs merge=lfs -text
Danger: The classic cross-platform bug: a Windows dev commits shell scripts with CRLF line endings; they fail on the Linux server withbad interpreter.*.sh text eol=lfin.gitattributesprevents it for everyone.
Git LFS (Large File Storage)
Git is terrible at large binaries (every version bloats the repo forever). Git LFS stores big files (videos, datasets, PSDs) outside the repo and keeps a small pointer in Git.
$ git lfs install
$ git lfs track "*.psd" # writes a .gitattributes rule
$ git add .gitattributes design.psd && git commit -m "Add design"
Tip: Rule of thumb: source code → Git; big binaries that change → Git LFS; huge static assets → object storage/CDN, not Git at all.