Batch convert text files from LF line endings to CRLF

convert lf to crlf
convert windows line endings to unix
convert windows line endings to unix notepad++
git line endings
git line endings best practice
check line endings windows
vim convert line endings
convert line feed to carriage return

I have a vb.net (visual studio 2010) project that is version controlled with git (1.7.10.msysgit.1). I made a mistake of leaving core.autocrlf to true in git. Now I have set core.autocrlf to false, but the source code is already converted to LF line endings inside the repository. I want to change the line endings back to CRLF.

My plan to correct the situation is:

  1. git clone
  2. delete all source code files in the clone
  3. git checkout -f
  4. convert all LF to CRLF
  5. git commit
  6. git pull from the original repo

I am having problem with step 4. There are a lot of files in the project and hopefully there is a tool to batch convert all text files into CRLF line endings.

I have tried dos2unix that is available in the git bash, but looks like it will not process subfolders and it told me that the text files looks binary.

So, what is the best way to batch convert my source code back to CRLF line endings?

I took Endy's steps but reduced it to just using one single repository:

1. git config core.autocrlf true
2. delete all files in your working tree (except the .git folder for sure)
3. git checkout -f
4. git config core.autocrlf false
5. git commit -am "corrected all line endings from LF to CRLF"

Batch convert text files from LF line endings to CRLF, I took Endy's steps but reduced it to just using one single repository: 1. git config core.autocrlf true 2. delete all files in your working tree (except  Using Notepad++ to change end of line characters (CRLF to LF) End of Line characters include CR or LF. Windows uses both CRLF at the end of a line, whereas Unix uses only a LF. CR = Carriage Return; LF = Line Feed

I missed the obvious way:

  1. git clone to folder A. git config core.autocrlf false
  2. git clone to folder B. git config core.autocrlf true
  3. delete all source files from folder B
  4. git checkout -f in folder B
  5. cut and paste all files and folders from folder B to folder A
  6. git commit in folder A
  7. git pull from the original repository

What is the easiest way to convert a bunch of text files from LF (Unix , What is the easiest way to convert a bunch of text files from LF (Unix) to CRLF (​Windows) in a single run? [duplicate] · windows unix newlines. This question  In the Windows text editing program Notepad++ (not to be confused with ordinary Notepad), there is a function to prepare text files with UNIX-style line endings. To write your file in this way, while you have the file open, go to the Edit menu, select the "EOL Conversion" submenu, and from the options that come up select "UNIX/OSX Format".

Christoph's answer almost worked for us but for some reason git missed a bunch of files. (We're on version 2.20). We had to force git to rescan everything via "git read-tree --empty". After doing this, some files showed as "delete" which was incorrect, but after a reset and add that worked for us.

1. git config core.autocrlf true
2. delete all files in your working tree (except the .git folder for sure)
3. git checkout -f
4. git config core.autocrlf false
5. git read-tree --empty
6. git add .
7. git reset
8. git add .
9. git commit -m "corrected all line endings from LF to CRLF"

Convert Unix line endings to Windows, You can convert them with the unix2dos utility on your Linux platform. changes LF endings into CR/LF for Windows, on all .txt files of the current directory, but NOT within subdirectories (no Batch/DOS one-liner (removes empty lines): 1. git config core.autocrlf true 2. delete all files in your working tree (except the .git folder for sure) 3. git checkout -f 4. git config core.autocrlf false 5. git commit -am "corrected all line endings from LF to CRLF"

How to bulk convert all the file in a file system branch between Unix , Everybody knows :-) that in Windows plain text files lines are terminated with CR+​LF, and in Unix&Linux - with LF only. How can I quickly convert all my source  runtask (sed command to convert LF to CRLF) Step03 (if step02 = 0 then) runtask (PGP-encrypt the new file as before) Step04 (if step03 = 0 then) continue processing as before. Send file on to next UNIX machine. In this scenario the customer would not have change anything. This will add a very small resource impact to that Linux box.

Convert the line endings in a text file from UNIX to , Most modern operating systems use the linefeed character (LF) as a line separator. The only notable exception is Microsoft Windows, which uses a carriage return  To convert the line endings in a text file from UNIX to DOS format (LF to CRLF) Background. Most modern operating systems use the linefeed character (LF) as a line separator. The only notable exception is Microsoft Windows, which uses a carriage return followed by a linefeed (CRLF).

Convert between Unix and Windows text files, The format of Windows and Unix text files differs slightly. In Windows, lines end with both the line feed and carriage return ASCII characters, but  Convert Unix, Windows, Mac line endings using OS X command Today I had to copy some MySQL data from Debian server into test environment on my MacBook. While importing data from tab delimited text files, I noticed warnings that data in the last column of several tables was being truncated.

Comments
  • Nice! But be careful if you have ignored / untracked files.