Skip to content
Edit this page View source of this page

Git file attributes

The root .gitattributes tells Git how to normalize line endings, show diffs, and handle files in archives. It applies during Git operations. EditorConfig controls how editors save files.

Template defaults

  • Git detects text files automatically. Shell scripts and Jupyter notebooks are set to use LF. Windows scripts and CSV files are set to use CRLF in the working tree.
  • Python and Markdown files have named diff drivers. Common image and archive formats are marked as binary. Patch files are exempt from text conversion.
  • Git archives omit repository housekeeping files such as .gitignore and .gitattributes according to their export-ignore attributes.

Inspect an attribute

From the repository root, ask Git which rules apply to the paths you're working with.

git check-attr text eol diff -- scripts/setup.sh README.md
git ls-files --eol -- scripts/setup.sh

Set attributes for new file types only when your project needs specific behavior. If you change line-ending rules in a project with existing files, review the normalization diff separately from functional edits. Git attributes reference