<p>So, you are all ready to do a big SVN Commit and it bombs because you have inconsistent line endings in some of your files.  Fun part is, you're looking at 1,000s of files spanning dozens of folders of different depths.</p>

<p>What do you do?</p>

[{'answer_id': 15711, 'author': 'OJ.', 'author_id': 611, 'author_profile': 'https://Stackoverflow.com/users/611', 'pm_score': 2, 'selected': False, 'text': '<p>Add a <a href="http://wordaligned.org/articles/a-subversion-pre-commit-hook" rel="nofollow noreferrer">pre-commit hook</a> which parses the file content and performs the munging of CRLF/LF/CR/etc for you before it\'s written to SVN.</p>\n'}, {'answer_id': 15764, 'author': 'Yuval F', 'author_id': 1702, 'author_profile': 'https://Stackoverflow.com/users/1702', 'pm_score': 2, 'selected': False, 'text': '<p>You may consider using a command like Linux\'s <a href="http://www.linuxcommand.org/man_pages/dos2unix1.html" rel="nofollow noreferrer">dos2unix</a> for the conversion. Being a Linux command, it is easy to use it in batch mode with scripts etc. I do not know whether there is an equivalent for other operating systems.</p>\n'}, {'answer_id': 16020, 'author': 'Cebjyre', 'author_id': 1612, 'author_profile': 'https://Stackoverflow.com/users/1612', 'pm_score': 6, 'selected': True, 'text': '<p>I don\'t think the <a href="http://svnbook.red-bean.com/nightly/en/svn.ref.reposhooks.pre-commit.html" rel="noreferrer">pre-commit</a> hook can actually change the data that is being committed - it can disallow a commit, but I don\'t think it can do the conversion for you.</p>\n\n<p>It sounds like you want the <a href="http://svnbook.red-bean.com/nightly/en/svn.ref.properties.html" rel="noreferrer">property</a> \'svn:eol-style\' set to \'native\' - this will automatically convert newlines to whatever is used on your platform (use \'CRLF\', \'CR\' or \'LF\' to get those regardless of what the OS wants).</p>\n\n<p>You can use <a href="http://subversion.apache.org/faq.html#auto-props" rel="noreferrer">auto-properties</a> so that all future files you create will have this property set (auto props are handled client-side, so you\'d have to set this up for each user).</p>\n'}, {'answer_id': 9727551, 'author': 'David W.', 'author_id': 368630, 'author_profile': 'https://Stackoverflow.com/users/368630', 'pm_score': 3, 'selected': False, 'text': '<p>First is to clean everything up. Are you on Windows or Unix/Linux/Mac?</p>\n\n<p>If you\'re on Unix/Linux/Mac, you can try something like this:</p>\n\n<pre><code>$ find . -type f -name "*.java" -exec dos2unix {}\\;\n</code></pre>\n\n<p>That\'s if you have <code>dos2unix</code> on your box. It\'s not on my Mac or any of the six Linux machines we have. Seems like we didn\'t install this particular package. Fortunately, it\'s easy enough to find.</p>\n\n<p>Be careful using it because you don\'t want to to munge binary files.</p>\n\n<p>Once you\'ve cleaned everything up, you should put the <code>svn:eol-style</code> property on your files. Setting it to <em>native</em> will checkout the file with the correct line ending for your machine, but store them in Unix line ending format. The other three options are "LF" for Unix, "CRLF" for Windows, and "CR" for pre Mac OS X Macs. Most people find "native" to work out the best. The only problem with Native is that it won\'t check in a file with mixed line endings while "LF" and "CRLF" will.</p>\n\n<p>Once you do that, you should get a <a href="https://github.com/qazwart/SVN-Precommit-Kitchen-Sink-Hook" rel="noreferrer">pre-commit hook</a> that will allow you to enforce line endings on particular files. Then, teach your developers to use <a href="http://svnbook.red-bean.com/en/1.7/svn.advanced.props.html#svn.advanced.props.auto" rel="noreferrer">autoproperties</a>. The pre-commit hook will prevent any commits unless the property is placed on the file A developer gets their commit rejected once or twice, and they\'ll setup auto properties on their own.</p>\n'}, {'answer_id': 59680444, 'author': 'freshNfunky', 'author_id': 8124631, 'author_profile': 'https://Stackoverflow.com/users/8124631', 'pm_score': 0, 'selected': False, 'text': '<p>you can use notepad++ to batch convert line endings.\nMake regex search:</p>\n\n<p><code>([^\\r])\\n</code></p>\n\n<p>and replace it with</p>\n\n<p><code>$1\\r\\n</code></p>\n\n<p>you then should choose a bunch of test files like:</p>\n\n<p><code>*.xml;*.txt;*.csv;...</code>asf.</p>\n\n<p>this avoids that you accidently modify binary files</p>\n\n<p><em>NOTE</em>: the regex patterns skip empty lines, so you have to run a second replace job with <code>\\n\\n</code> and replace it with <code>\\n\\r\\n</code></p>\n'}]
['https://Stackoverflow.com/questions/15687', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/307/']