What is the purpose of `text = auto` in the` .gitattributes` file?

advertisements

Mostly .gitattributes file has * text=auto. What is the purpose of text=auto in that file?


It ensures line endings are normalized. Source: Kernel.org

When text is set to "auto", the path is marked for automatic end-of-line normalization. If git decides that the content is text, its line endings are normalized to LF on checkin.

If you want to interoperate with a source code management system that enforces end-of-line normalization, or you simply want all text files in your repository to be normalized, you should instead set the text attribute to "auto" for all files.

This ensures that all files that git considers to be text will have normalized (LF) line endings in the repository.