Downloading via browser change line endings from CRLF to LF


I have problem, when I download text files from repo through a browser, line endings are replaced from CRLF to LF. Git clone work correctly. I have .gitattributes with config for this file but browser ommiting this config.

Thanks for help, best regards!

Hi @maciej.osuch
what’s your core.autocrlf setting?
I guess you have files with LF in repo, and browser isn’t really Git client. I don’t think it should follow .gitattributes which is processed by local Git client.
If you need files with CRLF in repo use core.autocrlf=false.

Hi @balonik,

I don’t have core.autocrlf set up.
My files were created with CRLF and that’s how they were uploaded to GitLab. When cloning a repository, the files are kept CRLF.
I understand that the browser is not a Git client and is skipping .gitattributes :sweat_smile:

I set the core.autocrlf option to false and pushed the files again but that didn’t help, browser still downloading with LF. Should I delete the remote repository and recreate it after changing core.autocrlf setting?

At least in GitLab Edit or WebIDE it is always LF, because of this. So avoid using the editor in UI if you need CR LF in repository.

AFAIK if you don’t set core.autocrlf it is false as default.
With core.autocrlf = false and manually changed file from LR to CR LF git diff should report it as a change

diff --git a/lf.txt b/lf.txt
index f4bf524..7e70244 100644
--- a/lf.txt
+++ b/lf.txt
@@ -1,6 +1,6 @@
-set me up
+set me up^M
\ No newline at end of file

It will be a new commit at least in my test-case. After push I’ve tried download the file using browser (Chrome) and it was downloaded with CR LF. I have tested on GitLab 13.10.2.

1 Like

Thank you for your response.

I had to delete .gitattributes because when changing the endings git did not treat it as a change and I got the message:
The file will have its original line endings in your working directory. Warning: LF will be replaced by CRLF in FILE.

I changed to LF, pushed the changes, then changed back to CRLF and pushed again and it works. Now I download via the web and the file has CRLF.
I don’t know why it didn’t work the first time. The file was created with CRLF.

Thank you for your help :slight_smile: