Git - 忽略位于存储库中递归允许所有内容的任何文件夹
Git - Unignore any folder located anywhere inside repository that recursively allows everything
如何取消忽略可以位于存储库内任何位置的具有特定名称(例如 Sync)的文件夹并递归地允许其中的所有内容,从而违反 gitignore 的所有其他规则?
更新:在 VONC 的回答中,他提到 !*/
和模式开头的斜杠是正确的。
取消忽略可以位于存储库内任何位置的具有特定名称(例如 Sync)的文件夹,并递归地允许其中的所有内容,这违反了 gitignore 的所有其他规则:
在 .gitignore 中添加以下内容:
*
!.gitignore
!*/
!/**/Sync/**
提出的解决方案 (!/**/Sync/**/*
) 无法单独使用,因为 It is not possible to re-include a file if a parent directory of that file is excluded.
因此,如果您有 .gitignore
并且:
*
!.gitignore
您必须先将文件夹列入白名单(!*/
),然后排除文件(!**/Sync/**
,不需要**/*
)
最终结果将是 .gitignore
,例如:
*
!.gitignore
!*/
!**/Sync/**
不要忘记检查任何适用 .gitignore
规则的文件:
git check-ignore -v -- aFile
注意:如果您想 锚定 来自 top[= 的白名单,则需要 /
(对于 !**/Sync/**
) 49=] 你的存储库。
如果不是,则不需要 /
:这将与您的 .gitignore
所在的位置有关)。
If the pattern does not contain a slash /
, Git treats it as a shell glob pattern and checks for a match against the pathname relative to the location of the .gitignore
file (relative to the toplevel of the work tree if not from a .gitignore
file).
如何取消忽略可以位于存储库内任何位置的具有特定名称(例如 Sync)的文件夹并递归地允许其中的所有内容,从而违反 gitignore 的所有其他规则?
更新:在 VONC 的回答中,他提到 !*/
和模式开头的斜杠是正确的。
取消忽略可以位于存储库内任何位置的具有特定名称(例如 Sync)的文件夹,并递归地允许其中的所有内容,这违反了 gitignore 的所有其他规则:
在 .gitignore 中添加以下内容:
*
!.gitignore
!*/
!/**/Sync/**
提出的解决方案 (!/**/Sync/**/*
) 无法单独使用,因为 It is not possible to re-include a file if a parent directory of that file is excluded.
因此,如果您有 .gitignore
并且:
*
!.gitignore
您必须先将文件夹列入白名单(!*/
),然后排除文件(!**/Sync/**
,不需要**/*
)
最终结果将是 .gitignore
,例如:
*
!.gitignore
!*/
!**/Sync/**
不要忘记检查任何适用 .gitignore
规则的文件:
git check-ignore -v -- aFile
注意:如果您想 锚定 来自 top[= 的白名单,则需要 /
(对于 !**/Sync/**
) 49=] 你的存储库。
如果不是,则不需要 /
:这将与您的 .gitignore
所在的位置有关)。
If the pattern does not contain a slash
/
, Git treats it as a shell glob pattern and checks for a match against the pathname relative to the location of the.gitignore
file (relative to the toplevel of the work tree if not from a.gitignore
file).