←back to thread

422 points km | 1 comments | | HN request time: 0s | source
Show context
djha-skin ◴[] No.41831122[source]
> Let's make CRLF one less thing that your grandchildren need to know about or worry about.

The struggle is real, the problem is real. Parents, teach your kids to use .gitattribute files[1]. While you're at it, teach them to hate byte order marks[2].

1: https://stackoverflow.com/questions/73086622/is-a-gitattribu...

2: https://blog.djhaskin.com/blog/byte-order-marks-must-diemd/

replies(2): >>41831938 #>>41832500 #
Kwpolska ◴[] No.41832500[source]
Nope. Git should not mess with line endings, the remote repository not matching the code in your local clone can bite you when you least expect it. On Windows, one should disable the autocrlf misfeature (git config --global core.autocrlf false) and configure their text editor to default to LF.
replies(3): >>41832761 #>>41833176 #>>41836850 #
djha-skin ◴[] No.41836850[source]
Sure, don't use autocrlf. But some _windows_ tools need crlf, like for powershell or batch build scripts. Defaulting to lf in the editor will not save you.

Don't use `auto`, full marks, but the gitattributes file is indispensable as a safety net when explicit entries are used in it.

I mean, the whole point of the file is not everyone who is working on the project has their editors set to lf. Furthermore, not every tool is okay with line endings that are not CRLF.

When used properly (sure, ideally without auto), the git attributes file as a lifesaver.

replies(2): >>41841607 #>>41852346 #
1. psd1 ◴[] No.41841607{3}[source]
Powershell doesn't care about line endings, and hasn't since 2006 when v2 was launched. I have never seen v1 installed but