Git Line Ending Control Guide | Generated by AI

Home 2025.09

git config core.autocrlf controls how Git handles line endings when you check files out of the repository and when you commit them back in. It matters because Windows uses CRLF (\r\n) for line endings, while Linux and macOS use LF (\n). Without handling, files may flip between formats depending on who edits them, leading to “dirty” diffs and unnecessary changes.


How it Works


Settings

You set it with:

git config --global core.autocrlf <value>

The common values:


Typical Recommendations

For mixed teams, it’s also good to add a .gitattributes file in the repo to enforce consistent line endings, e.g.:

* text=auto

Do you want me to also show you a recommended .gitattributes setup that works well for cross-platform teams (so you don’t rely only on core.autocrlf)?


Back Donate