Prevent EOL Normalization for CSV Files

I have an original repository that is used from both Windows and Linux .

I know that Git will automatically convert EOL to local standard: \ r \ n on Windows and n on Linux.

This is not a problem for source files.

But I have several CSV files that use a fixed format with the given character EOL ( \ r \ n ), which should not be changed, but Git will convert them too, breaking some code.

I tried to prevent EOL conversions for CSV files by creating a .gitattributes file in the root , next to a .gitignore file , with the following contents

*.csv    -text

I applied what I understood: http://git-scm.com/docs/gitattributes

But Git still converts \ r \ n to \ n on Linux.

Should I play with another parameter like auto.crlf?

Note that I am limited by the local Linux repository restriction, as it is managed by the Jenkins Continuous Integration Server .

Thanks for any input.

+4
source share
1 answer

, git LF EOL.

, *.csv , /.

, :

  • *.csv ,
  • .gitattributes, commit
  • *.csv ,

, :

### ... update .gitattributes
git rm --cached '*.csv'
### ... find -name '*.csv' -print0| xargs -0 unix2dos
git add '*.csv'
git add .gitattributes
git commit

:

  • git rm --cached csv , ;
  • , CRLF ( unix2dos)
  • git add '*.csv' , - , .gitattributes
+5

Source: https://habr.com/ru/post/1523822/


All Articles