Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/git/25.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
我可以从git lfs中排除一些文件吗?_Git_Atlassian Sourcetree_Git Lfs_Gitattributes - Fatal编程技术网

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

我可以从git lfs中排除一些文件吗?,git,atlassian-sourcetree,git-lfs,gitattributes,Git,Atlassian Sourcetree,Git Lfs,Gitattributes,我用一些图像文件创建了一个repo。我有要从lfs中排除的.gitignore和.git属性。所以我需要通过lfs跟踪所有文件,但不需要.gitignore和.gitattributes 我正在使用Sourcetree,并在.gittributes中尝试了这一点: .gitignore text .gitattributes text * filter=lfs diff=lfs merge=lfs -text 但是我的所有文件都被lfs跟踪。与.giti

我用一些图像文件创建了一个repo。我有要从lfs中排除的.gitignore和.git属性。所以我需要通过lfs跟踪所有文件,但不需要.gitignore和.gitattributes

我正在使用Sourcetree,并在.gittributes中尝试了这一点:

.gitignore      text
.gitattributes  text
*               filter=lfs diff=lfs merge=lfs -text

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

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

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


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

.gittributes
在优先级方面与
.gitignore
类似

*               filter=lfs diff=lfs merge=lfs -text
.gitignore      filter= diff= merge= text
.gitattributes  filter= diff= merge= text

这将取消对这些文件的筛选、差异、合并,lfs将不会跟踪它们。

我正在寻找相同的。我正在使用git的
2.26.2版,rkedge的答案对我来说并不适用。我发现并最终使用了:

*.dat         filter=lfs diff=lfs merge=lfs -text
excluded.dat  !filter !diff !merge text 

对于已经提交的文件,在修改
.gittributes

相关问题后,我必须取消跟踪并重新提交它们:这是应该接受的答案。我省略了我的存储库中的第二行
.gitinore filter=diff=merge=text
,在那里我使用git备份我的照片。