How does Git handle line-ending normalization, and what do core.autocrlf and .gitattributes settings do?
Last updated
Git can store text files with LF in the repo and convert line endings on checkout/commit. This avoids spurious diffs between Windows (CRLF) and Unix (LF) users.
core.autocrlfis a per-machine setting:trueconverts both ways (Windows),inputconverts to LF only on commit (Mac/Linux),falsedoes nothing..gitattributesis committed and overrides machine settings, so the whole team behaves consistently (e.g.* text=auto,*.png binary). It is the preferred approach.
- https://docs.github.com/articles/dealing-with-line-endings
- https://dev.to/kevinshu/git-and-normalization-of-line-endings-228j
- https://medium.com/towardsdev/line-endings-in-git-54d7f91e0daf
- https://dipakp-docs.readthedocs.io/git-knowledge/git-line-endings/index.html
- https://git-scm.com/docs/gitattributes
- https://mirrors.edge.kernel.org/pub/software/scm/git/docs/gitattributes.html
- https://community.br-automation.com/t/git-line-ending-configuration/4073
- https://git-scm.com/book/en/v2/Customizing-Git-Git-Configuration