我想忽略除特定子文件夹(及其所有内容!)以外的所有内容。我尝试了可能出现的重复问题的解决方案,但没有成功。
我需要一些简单的东西,例如:
*
!That/Very/Folder/*
Run Code Online (Sandbox Code Playgroud)
但这不起作用
Ger*_*eri 13
*
!*/
!That/Very/Folder/**
!Also/This/Another/Folder/**
Run Code Online (Sandbox Code Playgroud)
忽略所有内容,允许子文件夹 (!),然后允许特定文件夹内容(其中包含无限子文件夹)。
学分@Jepessen的中段,使得它的工作。
您.gitignore几乎可以使用,但它并非出于简单的原因:第一个规则(*)告诉Git忽略存储库根目录中的每个文件和目录。Git尊重它,并忽略一切,包括That目录及其内容。遵循的“ 忽略”规则与That子目录中的任何内容都不匹配,因为该That目录及其内容将被忽略,并且它们无效。
为了告诉Git不要忽略深度嵌套的子目录中的文件和目录,您必须编写忽略和取消忽略规则,以使其首先到达封闭的子目录,然后添加所需的规则。
您的.gitignore文件应如下所示:
### Ignore everything ###
*
# But do not ignore "That" because we need something from its internals...
!That/
# ... but ignore (almost all) the content of "That"...
That/*
# ... however, do not ignore "That/Very" because we need to dig more into it
!That/Very/
# ... but we don't care about most of the content of "That/Very"
That/Very/*
# ... except for "That/Very/Folder" we care
!That/Very/Folder/
# ... and its content
!That/Very/Folder/*
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
1775 次 |
| 最近记录: |