Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Almost four years after asking this question, I have finally found <strong>an answer that completely satisfies me</strong>!</p> <p>See the details in <strong>github:help</strong>'s guide to <a href="https://help.github.com/articles/dealing-with-line-endings/">Dealing with line endings</a>.</p> <blockquote> <p>Git allows you to set the line ending properties for a repo directly using the <a href="http://git-scm.com/docs/gitattributes#_checking-out_and_checking-in">text attribute</a> in the <strong><code>.gitattributes</code></strong> file. This file is committed into the repo and overrides the <code>core.autocrlf</code> setting, allowing you to ensure consistent behaviour for all users regardless of their git settings.</p> </blockquote> <p>And thus</p> <blockquote> <p>The advantage of this is that your end of line configuration now travels with your repository and you don't need to worry about whether or not collaborators have the proper global settings.</p> </blockquote> <p>Here's an example of a <strong><code>.gitattributes</code></strong> file</p> <pre class="lang-sh prettyprint-override"><code># Auto detect text files and perform LF normalization * text=auto *.cs text diff=csharp *.java text diff=java *.html text diff=html *.css text *.js text *.sql text *.csproj text merge=union *.sln text merge=union eol=crlf *.docx diff=astextplain *.DOCX diff=astextplain # absolute paths are ok, as are globs /**/postinst* text eol=lf # paths that don't start with / are treated relative to the .gitattributes folder relative/path/*.txt text eol=lf </code></pre> <p>There is a convenient <a href="https://github.com/Danimoth/gitattributes">collection of ready to use .gitattributes files</a> for the most popular programming languages. It's useful to get you started.</p> <p>Once you've created or adjusted your <strong><code>.gitattributes</code></strong>, you should perform a once-and-for-all <a href="https://help.github.com/articles/dealing-with-line-endings/#refreshing-a-repository-after-changing-line-endings">line endings re-normalization</a>.</p> <p>Note that the <a href="https://desktop.github.com">GitHub Desktop</a> app can suggest and create a <strong><code>.gitattributes</code></strong> file after you open your project's Git repo in the app. To try that, click the gear icon (in the upper right corner) > Repository settings ... > Line endings and attributes. You will be asked to add the recommended <strong><code>.gitattributes</code></strong> and if you agree, the app will also perform a normalization of all the files in your repository.</p> <p>Finally, the <a href="http://adaptivepatchwork.com/2012/03/01/mind-the-end-of-your-line/">Mind the End of Your Line</a> article provides more background and explains how Git has evolved on the matters at hand. I consider this <em>required reading</em>.</p> <p>You've probably got users in your team who use EGit or JGit (tools like Eclipse and TeamCity use them) to commit their changes. Then you're out of luck, as @gatinueta explained in this answer's comments:</p> <blockquote> <p>This setting will not satisfy you completely if you have people working with Egit or JGit in your team, since those tools will just ignore .gitattributes and happily check in CRLF files <a href="https://bugs.eclipse.org/bugs/show_bug.cgi?id=342372">https://bugs.eclipse.org/bugs/show_bug.cgi?id=342372</a></p> </blockquote> <p>One trick might be to have them commit their changes in another client, say <a href="http://www.sourcetreeapp.com">SourceTree</a>. Our team back then preferred that tool to Eclipse's EGit for many use cases.</p> <p>Who said software is easy? :-/</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload