我可以从 git-lfs 中排除一些文件吗?

Max*_*Max 14 git gitattributes atlassian-sourcetree git-lfs

我用一些图像文件创建了一个仓库。我有要从 lfs 中排除的 .gitignore 和 .gitattributes。所以我需要通过 lfs 跟踪所有文件,而不是 .gitignore 和 .gitattributes。

我正在使用 Sourcetree,我在 .gitattributes 中尝试过:

.gitignore      text
.gitattributes  text
*               filter=lfs diff=lfs merge=lfs -text
Run Code Online (Sandbox Code Playgroud)

但是我所有的文件都被 lfs 跟踪。

rke*_*dge 13

.gitattributes.gitignore与优先级类似。

*               filter=lfs diff=lfs merge=lfs -text
.gitignore      filter= diff= merge= text
.gitattributes  filter= diff= merge= text
Run Code Online (Sandbox Code Playgroud)

这将取消设置这些文件的过滤器、差异、合并,并且 lfs 不会跟踪它们。


log*_*cor 8

我正在寻找相同的。我使用的是git2.26.2 版,而 rkedge 的回答对我不起作用。我找到了这个线程并最终使用了:

*.dat         filter=lfs diff=lfs merge=lfs -text
excluded.dat  !filter !diff !merge text 
Run Code Online (Sandbox Code Playgroud)

对于已经提交的文件,我必须在修改后取消跟踪并重新提交它们.gitattributes


bk2*_*204 -3

与文件不同.gitignore.gitattributes文件没有排除模式,因此没有办法指定除少数文件之外的所有文件都应应用过滤器(如 Git LFS)。

您需要以不同的方式指定您的文件。如果所有文件都在一个目录中(例如,foo),则可以指定foo/**. 如果它们都是图像,您可以为每种类型的图像指定一个规则(例如,一个用于*.png,一个用于*.jpg,一个用于*.gif)。

最后的建议是,如果它们都以字母或数字字符开头,您可以指定[A-Za-z0-9]*,这也会排除所有点文件。