1

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?

Kefeng91
  • 802
  • 6
  • 10
  • 1
    This depends on your git config setting for `autocrlf`, try `git config --global core.autocrlf` and also [see here](https://stackoverflow.com/a/39077666/1505939) for global .gitattributes file possibility – M.M Jan 27 '20 at 02:44
  • If you managed to solve the problem then it'd be helpful to write an answer – M.M Jan 27 '20 at 03:25

1 Answers1

1

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.

VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250