git config core.autocrlf should default to false

And this should be configurable in the checkout action. The default should be false; otherwise a git checkout on Windows will often try to turn LF line endings into CRLF, which can easily break fragile files, such as expected output files for tests.

See https://travis-ci.community/t/files-in-checkout-have-eol-changed-from-lf-to-crlf/349 for the same thread over on Travis CI, which never got a fix.

I had to work around this with a .gitattributes file as follows:

* -text
10 Likes

Configuring your line endings with a .gitattributes file is the correct thing to do here, as that is the only way to check line ending configuration into the repository.

There has been mixed guidance throughout the years about the recommendations for core.autocrlf, but most has suggested core.autocrlf=true.  Most importantly, Git for Windows sets core.autocrlf=true in its installer.  Therefore, we too set core.autocrlf=true as our default.

However, you should not rely on core.autocrlf settings, you should configure the behavior you want with a .gitattributes file.  This is the only way to reliably deal with line endings in a repository.

2 Likes

Thanks for the reply. Good to know that at least this was a deliberate decision.

I still think this is the wrong decision to make, though. autocrlf is for humans, but GitHub Actions is not a human. It should check out a repository *exactly* as it was found.

I’d argue the opposite; if anyone really wants autocrlf to happen on CI, they should turn it on somehow.

Put it another way, I have dozens of repositories that have had zero need for a gitattributes file, but now this decision is forcing me to add the file everywhere, cluttering the repositories.

7 Likes

Fully agree with the OP. This setting is very cumbersome and we would like to be able to configure it as well, so we can deactivate it again.

1 Like

@mvdan wrote:

Thanks for the reply. Good to know that at least this was a deliberate decision.

 

I still think this is the wrong decision to make, though. autocrlf is for humans, but GitHub Actions is not a human. It should check out a repository *exactly* as it was found.

 

I’d argue the opposite; if anyone really wants autocrlf to happen on CI, they should turn it on somehow.

 

Put it another way, I have dozens of repositories that have had zero need for a gitattributes file, but now this decision is forcing me to add the file everywhere, cluttering the repositories.

This! It can cause serious issues! Please reconsider this.

Hi,

How would I be able to match

core.autocrlf=false

via a .gitattributes configuration?

I don’t really make sense of this doc.

Thanks

FYI all, a duplicate was filed as an issue on GitHub: https://github.com/actions/checkout/issues/135

Put it another way, I have dozens of repositories that have had zero need for a gitattributes file, but now this decision is forcing me to add the file everywhere, cluttering the repositories.

Not necessarily – use a global git attributes file. Example for a Windows machine:

.gitconfig

[core]
  attributesfile = C:\\Users\\thdoan\\Documents\\gitattributes_global.txt

The gitattributes file is for CI, not the local machine, so your solution does not apply.