7

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?

3 Answers3

10

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
anthony sottile
  • 61,815
  • 15
  • 148
  • 207
3

Something similar to this just worked for us.

*.asset filter=lfs diff=lfs merge=lfs -text
TheAssetIWantToExclude.asset !filter !diff !merge -text

This was for git version 2.17.1.windows.2 today. Comments further in Anthony Sottile's github link provided this answer.

For the existing file we used

git rm --cached TheAssetIWantToExclude.asset
git add TheAssetIWantToExclude.asset
git commit 

to get the file copied to the repo.

No Refunds No Returns
  • 8,092
  • 4
  • 32
  • 43
0

Check out this thread: Track all files in a directory to git LFS but ignore a single folder present in that directory

TL;DR, it's not possible unless you move the folder, or use git lfs track for each individual subdir.

garrettmills
  • 660
  • 6
  • 13