What problem does it solve?
gitattributes prevents inconsistent line endings, unstable diffs, and spurious merge conflicts by enforcing repository-wide Git file attributes and GitHub linguist behavior.
Core Features & Use Cases
- Line-ending normalization: Forces consistent
text handling and eol policies (e.g., LF for shell scripts, CRLF for Windows batch files).
- Diff and merge control: Marks binary files to avoid noisy diffs and applies merge strategies (including custom merge drivers) to reduce lockfile churn.
- GitHub linguist overrides: Stabilizes language statistics by flagging generated files or setting explicit linguist language/diff suppression behavior.
- Precedence-aware rules: Uses the correct matching patterns and understands override ordering between directory-level attributes and
$GIT_DIR/info/attributes.
Quick Start
Tell your AI assistant to generate a .gitattributes that sets LF line endings for *.sh, CRLF for *.cmd, marks images as binary to suppress diffs, and configures lockfile merge strategy for .github/workflows/*.lock.yml.