Development environment - copy code under windows to linux, ^M (newline conversion) appears at the end of the line

 

When developing, copy the script under windows to the linux file, and an error is reported when executed:

-bash: ./package.sh: /bin/sh^M: bad interpreter: No such file or directory

Obviously see "^M" appearing at the end of the line,

 

The solution is to use the "dos2unix" command to convert, the execution will not cause problems

dos2unix package.sh

 

通过命令git diff查看修改,出现^M换行问题,如图:

 

Solution (Pro test this is easy to use):

1

git config --global core.whitespace cr-at-eol

  

Problems with line breaks:

Converted to LF when submitted, not converted when checked out

git config --global core.autocrlf input

 

Guess you like

Origin blog.csdn.net/Ivan804638781/article/details/96132444