Change CRLF to LF

January 27, 2026

Change CRLF to LF

When collaborating between Windows and Mac/Linux environments, git diff can get messy due to line ending differences.
This difference occurs because Windows uses CRLF (\r\n) and Unix-based systems (Mac, Linux) use LF (\n), and it is naturally better to unify them.
A good way to unify to LF within a Git project is to set up .gitattributes and renormalize existing files.

1. .gitattributes Settings

Create (or modify) the .gitattributes file and add the following content.
This setting forces LF line endings for all text files.
.gitattributes
shell

2. Renormalize

If there are files already added with CRLF, you can renormalize and commit them.
If you are using git 2.16 or higher, you can use the --renormalize option.
Renormalize
shell
If you are using git version below 2.16 or want to change it manually, you can simply modify it in the shell.
Jooojub
System S/W engineer
Explore Tags
Series
    Recent Post
    © 2026. jooojub. All right reserved.