gitattributes

Define and modify .gitattributes rules for line endings and merge drivers.

3|1|Updated Apr 12, 2026
One-click install
npx skills add https://github.com/Cogni-AI-OU/cogni-ai-agent-skills --skill gitattributes
Or copy as Structured Prompt for Agentā–¼
Please help me install this Agent Skill.
Skill: gitattributes
Source: https://github.com/Cogni-AI-OU/cogni-ai-agent-skills/tree/main/gitattributes
Command: npx skills add https://github.com/Cogni-AI-OU/cogni-ai-agent-skills --skill gitattributes

SYSTEM DOCUMENTATION & REQUIREMENTS

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.

Frequently Asked Questions about gitattributes

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I normalize line endings in Git for cross-platform development?ā–¼

You normalize line endings by defining text and eol policies in a .gitattributes file, setting LF for scripts and CRLF for Windows files, then running git add --renormalize to safely apply the new rules across the repository.

Why does Git show noisy diffs for binary files and how can I suppress them?ā–¼

Git shows noisy diffs for binary files because it lacks specific attribute rules. You suppress these noisy diffs by marking images and auto-generated assets as binary in your .gitattributes file, which prevents Git from attempting to render textual changes for those paths.

Can I configure a custom merge driver in Git to reduce lockfile conflicts?ā–¼

Yes, you can configure custom merge drivers and merge strategies in .gitattributes to reduce lockfile churn and spurious merge conflicts. This applies specific conflict resolution behaviors to matching file paths like .lock.yml files.

How do I fix incorrect GitHub language statistics for generated files?ā–¼

You fix incorrect GitHub language statistics by adding linguist overrides to your .gitattributes file. Flagging auto-generated files or setting explicit linguist language and diff suppression behavior stabilizes your repository's language breakdown.

What is the correct precedence for Git attributes between directory rules and $GIT_DIR/info/attributes?ā–¼

Git attributes precedence follows pattern matching correctness and override ordering, with directory-level .gitattributes rules being applied based on their path depth. Understanding this override ordering is necessary to ensure local info/attributes rules interact correctly with repository-wide rules.