Files in checkout have EOL changed from LF to CRLF


The checkout is changing line endings of files. This can lead to automated checks such as go fmt failing. In my case I have testdata where the byte offset of tokens is important, leading to my tests failing.

I use the following step to adjust files back to LF

- find . -name '*.go' -type f -print0 | xargs -0 sed -i ':a;N;$!ba;s/\r//g'

I tried to unset the “text” gitattribute, which according to gits documentation should prevent automatic line ending changes. However, the issue still persisted. For reference I have the following for my .gitattributes:

# We have tests which parse files and fail if file offsets change. So disable
# EOL conversions.
**/testdata/* -text

The PR which enabled windows support is
I originally mentioned this issue in another discussion Go can't find GCC with go1.11.1 on Windows

Go can't find GCC with go1.11.1 on Windows

You might be able to do it with gitattributes, but a bit different syntax. For example:
* text=auto
*.js text eol=lf
*.sass text eol=lf
*.json text eol=lf
*.css text eol=lf
*.html text eol=lf
*.htm text eol=lf


The issue here appears to be that git is configured as follows (taken from a Windows-based build):

$ git config -l

This feels like the wrong default ( because otherwise there’s a considerable amount of work required to undo this behaviour. If anything, I would suggest making the default false and then allowing people to configure it to true in the .travis.yml git: section (

My current work around is the following addition to my .travis.yml:

  - cd ../..
  - mv $TRAVIS_REPO_SLUG _old
  - git config --global core.autocrlf false
  - git clone --depth=50 _old $TRAVIS_REPO_SLUG

Edit to fix env var name

Edit to fix error in before_install

Feature request: Update Git configure `core.autocrlf`

An update on my side. I have not tried travis windows support since I originally posted this issue. We ran into other issues so I am unsure what the current status of this is.

@AviVahl hi Avi sorry I missed your response. Unsetting the text attribute should disable any EOL conversions in git, which is what I did in the gitattributes. Forcing the line endings sounds like a reasonable workaround (for text data), but either way the proper gitattribute is not being respected. According to the git documentation it should work, but maybe there is an outdated windows version in the image?


In rust-clippy we managed to work around this using the dos2unix utility on affected files:


Another workaround would be to use the .gitattributes file and enforce LF for lineendings:

# ./.gitattributes

* text=auto eol=lf