简体   繁体   中英

How to fix windows line endings after git clone

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.

How should I fix it?

I think I should clone my repo again with correct line endings, and move over my changes manually.

How do I clone it properly, so that all line ending are \\r\\n?

Are there any better suggestions?

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 link that birryree pointed out in the comments is a good source. There is also Github's help page on it.

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

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

Another way is to run the dos2unix win32 utility found here .

Info: dos2unix.exe converts MS-DOS text files to Unix format, by stripping any CR or end-of-file ( Ctrl - Z ) characters from the data.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM