This is pretty good advice. I have been using a combination of editorconfig files with pre-commit hooks to run linting and formatting which enforces 'eol'.
Your solution is more elegant. Reading the github reference on this, it might be better to do it this way, using auto.
# Set the default behavior, in case people don't have core.autocrlf set.
This way, whatever OS you are no, git will decide the correct 'eol' to apply for you.
We're a place where coders share, stay up-to-date and grow their careers.
We strive for transparency and don't collect excess data.