How to make git LFS not apply to a subdirectory

Viewed 2022

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 Answers

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.

Related