Control Line Endings With .gitattributes
Normalize CRLF/LF per file type so diffs stay clean across platforms.
Add *.sh text eol=lf to .gitattributes to enforce LF for shell scripts.
01Command
Command
$ git config core.autocrlf input # plus .gitattributes02What it does
Line-ending drift causes noisy diffs and broken scripts; committing a .gitattributes file applies rules consistently for every clone, unlike local core.autocrlf settings that differ per machine. It is configuration as code.
03Risk
!Warning: Changing line-ending rules can produce a large one-time diff; coordinate with the team before converting a repository.
04Undo
✓No undo needed — this command does not change persistent state.
05Sources
- git-gitattributes documentationEvidence: Documents .gitattributes, including the text and eol attributes.
Last verified: 2026-10-13 · Category: Developer