GIT does not accept text files in DOS style with CRLF characters at the end of the lines. Although it’s possible to configure repository to auto-convert line endings, the files in your local copy will remain in DOS-style. The script below, assuming it’s saved as fromdos.sh, will prepare your files by removing CR character.
It can be triggered in two ways:
conversion of a single file
conversion of multiple files
1 | ls *.php | xargs fromdos.sh |
Copy the test below and save it as fromdos.sh file in a directory in your PATH. Make sure it’s executable
and run it from any place
10 | die "Usage: `basename $0` file_to_convert \n You can also xargs multiple file by: ls *.php | xargs `basename $0`" |
15 | cat $toconv | tr -d '\015' > $toconv.tmp |
17 | mv $toconv.tmp $toconv |