Bash scripts Git cloned in VSCode are automatically converted to DOS format

652 views Asked by At

Platform: Windows 10 Editor: VSCode

Hi,

I am working on Windows using WSL and develop on VSCode. I notice that whenever I clone a project that contains Bash scripts into VSCode, these scripts are automatically converted to DOS format which means that I have to dos2unix these scripts before being able to use them.

For instance, if I clone this repo full of Bash scripts in VSCode, and check any script using the command dos2unix --info=u *, it returns 0 for every Bash scripts which means they are not Unix-formatted.

However, if I simply download the repo directly from GitHub and check the info of the scripts, it shows that they are actually Unix-formatted.

Is there a way to avoid this automatic conversion and simply clone the repo as it is?

1

There are 1 answers

0
VonC On

I always start with git config --global core.autocrlf false: that takes care of any autmomagic conversion (which would be done by default on all files)
This is respected by VSCode.

Any eol conversion should be, as commented, done in a .gitattributes file if needed, as I wrote here: that way, even if core.autocrlf was left to true, it would not convert those files.