Ignoring everything in .gitignore and adding subfolder does not work

早过忘川 提交于 2019-12-08 13:29:24

You need to whitelist folders first, then files:

*
!.gitignore
!/mainfolder/
/mainfolder/*
!/mainfolder/subfolder/
!/mainfolder/subfolder/**

For any file still ignored, check why with:

git check-ignore -v -- path/to/ignored/file

would it be possible to extend the answer on how you would do this for a deeper subfolder? E.g. how would I ignore everything except ´deepsubfolder´(?): !/mainfolder/subfolder/deepsubfolde

That is similar to "Git - Unignore any folder located anywhere inside repository that recursively allows everything":

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