explaingit

gitattributes/gitattributes

3,791Git AttributesAudience · developerComplexity · 2/5Setup · easy

TLDR

A community-maintained collection of .gitattributes template files that tell Git how to handle file types, line endings, and syntax highlighting across operating systems, preventing false change detections in your projects.

Mindmap

mindmap
  root((gitattributes))
    Templates
      Common rules
      Language specific
      Project types
    Line Endings
      Cross OS safety
      Text vs binary
    GitHub Display
      Syntax highlighting
      File identification
    Tools
      Online generators
      check.sh script
    Contributing
      Fork and PR
      One file per commit
Click or tap to explore — scroll the page freely

Code map

Detail Auto

An interactive map of this repo's files and how they connect — its source is parsed live in your browser. Click Visualize to build it.

filefunction / class

Things people build with this

USE CASE 1

Set up correct line ending rules for a project that runs on both Windows and Mac or Linux machines.

USE CASE 2

Ensure GitHub shows proper syntax highlighting for your project's file types.

USE CASE 3

Audit your repository to find file types that have no .gitattributes rule yet, using the included check.sh script.

USE CASE 4

Quickly generate a ready-to-use .gitattributes file by combining templates via one of the linked online tools.

Tech stack

GitShell ScriptGit Attributes

Getting it running

Difficulty · easy Time to first run · 5min

No installation needed. Copy the relevant template file into your project root as .gitattributes, or use one of the linked online generator tools to combine templates automatically.

No license explicitly mentioned in the explanation.

In plain English

This repository is a collection of template files for Git's .gitattributes system. A .gitattributes file sits in the root of a code project and tells Git how to handle specific types of files: whether to treat them as text or binary, how line endings should be managed across different operating systems, and how files should be identified for things like syntax highlighting on GitHub. Without these instructions, Git sometimes makes wrong guesses that cause files to appear changed when nothing meaningful actually changed. The project is modeled after the well-known .gitignore templates collection, which does a similar job for telling Git which files to ignore entirely. Here the focus is on attributes rather than exclusions. The repository includes a file called Common.gitattributes with general rules that could apply to almost any project, as well as more specialized templates for specific languages or project types. Two online generator tools are linked in the README. These let you pick from the templates in this repository and combine them into a single .gitattributes file for your project without manually reading through everything yourself. For teams who want to automate quality checks, the README includes a shell script snippet that scans all files in a repository and reports which ones lack a corresponding .gitattributes rule. A more fully featured version of this check is included as check.sh in the repository itself, with a help flag to see its options. Contributions to the collection are welcome via the standard GitHub fork-and-pull-request process. The main house rule is to keep each commit to a single file change so that merges stay clean. The project is a community-maintained reference rather than a software tool you install.

Copy-paste prompts

Prompt 1
What does the Common.gitattributes file cover and which of its rules should I add to my project?
Prompt 2
How do I use check.sh to find files in my repo that are missing a .gitattributes rule?
Prompt 3
Which template should I use for a JavaScript or TypeScript project, and what line ending setting is recommended?
Prompt 4
How do I combine multiple templates from this collection into one .gitattributes file for my project?
Prompt 5
What is the difference between marking a file as text versus binary in .gitattributes, and when does it matter?
Open on GitHub → Explain another repo

← gitattributes on gitmyhub — every repo by this author, as a profile.

Verify against the repo before relying on details.