Bash - seamlessly run scripts with CRLF line endings

后端 未结 4 1027
栀梦
栀梦 2020-12-31 03:45

I am using VM (in my case simply boot2docker) to run docker containers on Windows host. For convinience, my source files are mapped from host file system, so text files are

4条回答
  •  刺人心
    刺人心 (楼主)
    2020-12-31 04:32

    You can commit a .gitattributes file in your repo in the root folder to automatically tell Git to apply LF line endings to all .sh files when checking out, even on Windows. This way you or other developers don't have to remember to configure Git on each machine where you clone your repo.

    # Set line endings to LF, even on Windows. Otherwise, execution within Docker fails.
    # See https://help.github.com/articles/dealing-with-line-endings/
    *.sh text eol=lf
    

提交回复
热议问题