You can also provide a special --global flag, which makes Git use the
same settings for line endings across every local Git repository on
your computer.

After you've set the core.autocrlf option and committed a
.gitattributes file, you may find that Git wants to commit files that you have not modified. At this point, Git is eager to change the
line endings of every file for you.

The best way to automatically configure your repository's line endings
is to first backup your files with Git, delete every file in your
repository (except the .git directory), and then restore the files
all at once.
Save your current files in Git, so that none of your work is lost.