gitgit-lfsgitattributes

How to make git LFS not apply to a subdirectory


My repository uses git LFS and includes lines such as this one in its .gitattributes:

*.jar filter=lfs diff=lfs merge=lfs -text

There's one .jar file that I want to store in the repo directly, not involving LFS. Ideally, I would make LFS not apply to anything under the directory that contains that jar. Is there a way to do that?


Solution

  • This answer is largely sourced from this github comment

    The syntax for .gitattributes allows you to "minus" an attribute -- removing it from already being included (see: https://git-scm.com/docs/gitattributes#gitattributes-Unset)

    This allows you un-lfs a file that was previously included (the example from the github thread):

    *.asset filter=lfs diff=lfs merge=lfs -text
    Assets/Resources/*.asset -filter=lfs -diff=lfs -merge=lfs -text