windows git clone后如何修复windows行尾
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/7850909/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to fix windows line endings after git clone
提问by Arne Lund
I have cloned a repository from github on a Windows 7 box, and made some of changes I would hate to lose. However, all my file have wrong line endings, \n instead of \r\n.
我在 Windows 7 机器上从 github 克隆了一个存储库,并做了一些我不想丢失的更改。但是,我所有的文件都有错误的行尾,\n 而不是 \r\n。
How should I fix it?
我该如何解决?
I think I should clone my repo again with correct line endings, and move over my changes manually.
我想我应该用正确的行结尾再次克隆我的 repo,并手动移动我的更改。
How do I clone it properly, so that all line ending are \r\n?
如何正确克隆它,以便所有行结尾都是 \r\n?
Are there any better suggestions?
有没有更好的建议?
回答by Andy
You can't clone the repository with a different style of line endings. The data in the repository is what it is. What you can do is tell git how you want to handle the line endings when checking in or out. The linkthat birryree pointed out in the comments is a good source. There is also Github'shelp page on it.
您不能克隆具有不同行尾样式的存储库。存储库中的数据就是它。您可以做的是告诉 git 在签入或签出时您希望如何处理行尾。birryree 在评论中指出的链接是一个很好的来源。Github 上也有帮助页面。
Depending on what you are editing, you can also use a Windows text editor that doesn't require crlf, like notepad++. You can change the line endings that notepad++ uses by default in settings->preferences->New Document/Default Directory
根据您正在编辑的内容,您还可以使用不需要 crlf 的 Windows 文本编辑器,例如notepad++。您可以更改 notepad++ 默认使用的行尾settings->preferences->New Document/Default Directory
To add from Charles' comment, you can also convert line endings to unix or windows style in notepad++. You do this by going to edit->EOL Conversion
要从 Charles 的评论中添加,您还可以在 notepad++ 中将行尾转换为 unix 或 windows 样式。你这样做edit->EOL Conversion