Add .gitattributes to enforce LF line endings and prevent cross-platform issues
Problem
The project has no .gitattributes file. With multiple developers working on different OS (Windows, Linux, macOS), Git auto-conversion and inconsistent line endings cause issues:
-
CRLF leaks: 6 files already have CRLF in the repository (mostly in
google-translate-example/andmobile/) - No binary file detection: Large files (models, images) may be treated as text by Git
- No merge driver: Merge conflicts on files with different line endings are harder to resolve
Proposed Solution
Add a .gitattributes file at the repository root covering:
-
Line ending normalization: Force LF for all text files (
* text=auto eol=lf) - Binary detection: Images, fonts, PDFs, archives, certificates, databases
- Language-specific: Python (PEP 8), Shell (POSIX), Dart (Flutter convention)
- Docker / CI: Dockerfile, docker-compose, .env*
- Web assets: CSS, SCSS, JSON, YAML, TOML, Vue, TypeScript
-
IDE configs:
.vscode/,.idea/(binary detection for workspace files)
After adding .gitattributes, existing files need a one-time normalization:
git add --renormalize .
git commit -m "chore: normalize line endings via .gitattributes"