问题描述
我想在Assets目录和所有子目录中包含所有* .meta文件,同时排除Assets中的所有其他内容
I want to include all the *.meta files in the Assets directory and all subdirectories while excluding everything else in Assets
我尝试过
/Assets/*
!/Assets/**/*.meta
!*.meta
但是在/Assets中仅包含* .meta吗????
but that only include *.meta within /Assets ????
感谢您的帮助
推荐答案
首先,如果忽略规则不起作用,则可以检查此使用git check-ignore
:
First, if an ignore rule does not work, you can check this with git check-ignore
:
git check-ignore -v -- yourFile
它将显示哪个忽略规则忽略了您认为不应忽略的文件.
It will display which ignore rule ignore a file that you thought should not be ignored.
然后要记住的主要规则是:
Then the main rule to remember when it comes to ignore is:
这就是为什么您的规则仅在/Assets
(而不是子目录)中包括*.meta
的原因
That is why your rules only include *.meta
within /Assets
(and not the subdirectories)
您需要包括文件的所有父文件夹(例如,在最近的示例中为 ),以便包括文件
You would need to include all parent folders of a file (as in this recent example) in order to include a file
/Assets/**/**
! /Assets/**/
!/Assets/**/*.meta
我使用git 2.4.1对其进行了测试,并且可以正常运行(即使在Windows上也是如此).
它确实仅包括Assets
和所有子目录中的*.meta
文件,但排除其他所有内容.
I tested it with git 2.4.1 and it works (even on Windows).
It does include only the *.meta
files in Assets
and all subdirectories, but exclude everything else.
请注意,使用git 2.9.x/2.10(2016年中吗?),如果排除了该文件的父目录,则可能可以重新包含该文件如果重新添加的路径中没有通配符.
Note that with git 2.9.x/2.10 (mid 2016?), it might be possible to re-include a file if a parent directory of that file is excluded if there is no wildcard in the path re-included.
NguyễnTháiNgọcDuy(pclouds
)试图添加此功能:
Nguyễn Thái Ngọc Duy (pclouds
) is trying to add this feature:
- 为git v2.7.0提交506d8f1 ,已在提交76b620d git v2.8.0-rc0
- 提交5e57f9c git v2.8.0-rc0,...还原(! )在提交5cee3493 git 2.8.0-rc4.
- commit 506d8f1 for git v2.7.0, reverted in commit 76b620d git v2.8.0-rc0
- commit 5e57f9c git v2.8.0-rc0,... reverted(!) in commit 5cee3493 git 2.8.0-rc4.
但是,由于重新纳入的条件之一是:
However, since one of the condition to re-inclusion was:
那在这里是行不通的.
这篇关于在gitignore中包括特定的文件扩展名的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!