Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>For what you are trying to do I think you need the following. Note that the eol attribute according to the gitattributes man page may be either "lf" or "crlf". Native is for the core.eol config setting.</p> <p>Set core.autocrlf false to take explicit control of normalization. Now only files you mark with the text attribute will undergo normalization.</p> <p>Either set the eol attribute explicitly to lf or crlf for specific filetypes (eg: shell scripts may require lf to work on unix, .csproj files may require crlf on windows). If the eol attribute is unset the value of core.eol should be used. If you set core.eol to crlf then your text files will get crlf endings.</p> <p>Here is a git test script to illustrate this (run from git/t/):</p> <pre><code>#!/bin/sh test_description='check native crlf setting' . ./test-lib.sh has_cr() { tr '\015' Q &lt;"$1" | grep Q &gt;/dev/null } test_expect_success 'test native elf' ' printf "*.txt text\n" &gt; .gitattributes printf "one\r\ntwo\r\nthree\r\n" &gt; filedos.txt printf "one\ntwo\nthree\n" &gt; fileunix.txt git init &amp;&amp; git config core.autocrlf false &amp;&amp; git config core.eol crlf &amp;&amp; git add . &amp;&amp; git commit -m "first" &amp;&amp; rm file*.txt &amp;&amp; git reset --hard HEAD &amp;&amp; has_cr filedos.txt &amp;&amp; has_cr fileunix.txt ' test_done </code></pre> <p>With the above config and attributes, with Git for Windows 1.8.0 both files are normalized after the reset and contain crlf line endings.</p> <p>Where a bug may exist is that if the core.eol variable is left unset (or set to 'native') this test fails as the files are normalized to lf line endings in this case. The path you have mentioned above does not help this situation either. So from my testing, you must explicitly set core.eol to crlf to have your planned approach be successful.</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. 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.
    1. COThanks - I had put the `eol=native` in an attempt to force this. I know that setting `eol=crlf` would make checkouts use crlf and that some files might need either lf or crlf to work (none of the ones I posted though). But this is a full time bug : on windows _native_ is CRLF - if I put this in my gitattributes it completely defeats its purpose - my linux collaborators would get CRLFs too ! The situation was much better with the `--global core.autocrlf` then !!! This must be fixed - I repeat checking out (via `reset, checkout, clone etc`) on windows should produce CRLF when `core.eol=native`
      singulars
    2. COLook carefully - if you set the attributes for these files just to 'text' and then configure your repository to use core.eol=crlf then your unix users will have their own core.eol setting (ie: lf) and it will work for everyone. core.eol = native does not currently work - this is a bug which i've now proposed a fix for and should be resolved in the next release. For now - 'git config core.eol crlf' and do not set eol in the attributes at all.
      singulars
    3. COThanks - I got that - that's what I meant with the _The situation was much better with the --global core.autocrlf then_ - I have to set a global preference as it is _and_ have the gitattributes (while before it was only a global :). Please link to the bug report/fix you made in your answer so I can accept it.
      singulars
 

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