How do I set all files in a subdirectory to use a specific eol using gitattributes?

I’ve been trying to set specific files to always use lf and not crlf regardless of autocrlf on the local system.

I tried creating a .gitattributes at the root of the project that only contained SquishIt.Tests/js/*.js eol=lf and I also tried SquishIt.Tests/js/ eol=lf. I pushed both of these attempts to my remote and then tried cloning it locally twice. The files under /js/ always showed up with CR+LF in both cases as autocrlf is on globally for me.

  • How to move HEAD to other branch in Git without checking out files or updating any refs?
  • In Git, I get an error when I try to delete my local branch
  • how can i configure android studio to add new line at end of file?
  • Is there a way to run git rebase --abort without switching branches?
  • Git flow and Github
  • Using Composer and Private Repository on GitHub using VCS on Build Server
  • I’m on a Windows machine, just in case it was unclear. Is what I’m attempting to achieve even possible?

  • In a GIT bugfix branch, how to pull and then remove another branch (just to test it together)?
  • Duplicate builds triggered on Jenkins multibranch pipeline
  • Does anyone here fork themself?
  • apparently same commits give different sha1, why?
  • Finding out which files are version controlled that now match the current .gitignore
  • Creating a duplicate git commit
  • 2 Solutions collect form web for “How do I set all files in a subdirectory to use a specific eol using gitattributes?”

    I wanted to have all text files forced to use LF except one sub directory (.idea) which is forced to use ‘CRLF’. This is how my .gitattributes looks:

    * text eol=lf
    /.idea/* text eol=crlf

    So I assume yours should look like:

    * text=auto
    /SquishIt.Tests/js/* text eol=lf

    I would set autocrlf to false and set core.whitespace to cr-at-eol. It’s better to let your editors deal with the difference in line endings. Let git store them as they are.

    Hope this helps.

    Git Baby is a git and github fan, let's start git clone.