git ignore exception not working multiple subdirectories below ignored directory

自闭症网瘾萝莉.ら 提交于 2019-12-08 06:57:27
tanius

Re-including a file that "is multiple subdirectories below the ignored directory" (as you try), does not work because "It is not possible to re-include a file if a parent directory of that file is excluded" [source].

As an ugly-but-working workaround, re-include all parent directories along the path before re-including your desired file, while keeping the files in these parent directories out by re-excluding them.

For your example it would like as follows:

web/[Ee]xample.[Ww]eb/[Ss]itecore/*

!web/[Ee]xample.[Ww]eb/[Ss]itecore/[Ss]hell/
web/[Ee]xample.[Ww]eb/[Ss]itecore/[Ss]hell/**
!web/[Ee]xample.[Ww]eb/[Ss]itecore/[Ss]hell/[Tt]hemes/
web/[Ee]xample.[Ww]eb/[Ss]itecore/[Ss]hell/[Tt]hemes/**
!web/[Ee]xample.[Ww]eb/[Ss]itecore/[Ss]hell/[Tt]hemes/[Ss]tandard/
web/[Ee]xample.[Ww]eb/[Ss]itecore/[Ss]hell/[Tt]hemes/[Ss]tandard/**
!web/[Ee]xample.[Ww]eb/[Ss]itecore/[Ss]hell/[Tt]hemes/[Ss]tandard/[Cc]ustom/
web/[Ee]xample.[Ww]eb/[Ss]itecore/[Ss]hell/[Tt]hemes/[Ss]tandard/[Cc]ustom/**
!web/[Ee]xample.[Ww]eb/[Ss]itecore/[Ss]hell/[Tt]hemes/[Ss]tandard/[Cc]ustom/32x32*

Source: my related answer here.

Alternatively, you could instead use .gitignore files that are placed in the directory of files to re-include [more here]. Depending on taste, this could be the prettier solution.

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!