'How to stop github from modifying my files (in workflow)?
On github.com, I have a little 6-byte file hello.txt consisting of "hello" and a newline:1
In an Ubuntu-18 workflow with runs-on: ubuntu-18.04, we have:
But on Windows with runs-on: windows-2019, there is miraculously an extra byte:2
How do I get rid of this extra byte?
Update: After studying James' quick answer, I opted for a one-line .gitattributes file in the directory where my hello.txt was located:
* -text
That directory consists of test data only.
1 I do not know why GitHub drops the .txt extension, but I am an newbie.
2 We can all assume the extra byte is a carriage-return.
Solution 1:[1]
Line ending handling can be configured in quite a few different ways.
I'm pretty sure on Windows when you install git, there's a popup where it asks you how you want to handle CRLF's, but it's been a while since I did a fresh install.
Check out the official docs here on how you can configure it: https://docs.github.com/en/github/getting-started-with-github/configuring-git-to-handle-line-endings
From the Docs on the .gitattributes options:
text=autoGit will handle the files in whatever way it thinks is best. This is a good default option.text eol=crlfGit will always convert line endings toCRLFon checkout. You should use this for files that must keepCRLFendings, even on OSX or Linux.text eol=lfGit will always convert line endings toLFon checkout. You should use this for files that must keepLFendings, even on Windows.binaryGit will understand that the files specified are not text, and it should not try to change them. The binary setting is also an alias for-text -diff.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | James |



