amended line ending with Vagrant & ZSH

2019-09-08 15:31发布

问题:

I have a vagrant box where I change the default Ubuntu shell to oh-my-zsh. I have a shared folder containing a .zshrc that I copy to the vagrant home folder during provisioning. At some point the line ending for one line in the .zshrc has ^M appended to it so I get the following error when I vagrant ssh:

/home/vagrant/.zshrc:source:4: no such file or directory: /home/vagrant/.oh-my-zsh/oh-my-zsh.sh^M

The ^M is not visible in the .zshrc file. If I use vim in the vagrant box and re-write the .zshrc file then everything works as expected.

How can I ensure my .zshrc won't have this line ending character appended during the process of git clone-ing the repo and vagrant up-ing the box?

I'm using Vagrant in Windows 7.

回答1:

based on this you can make the following setting in git

git config --global core.autocrlf false
git config --global core.eol lf

and you will have no issues when cloning the project