How to gitignore everything except hidden subdir?

▼魔方 西西 提交于 2019-12-11 16:28:19

问题


I'm using this .gitignore file for excluding everything in the current dir and subdirs, except the ! prefixed entries:

*
!.profile
!.vim/snippets
!.vimrc

The .profile and .vimrc files are showing up as untracked in git status but not the .vim/snippets directory. Any idea how to include this directory as well? I've tried !.vim/snippets/ but it doesn't work either. Thanks


回答1:


I found a solution that works OK. One can explicitly say what dirs and files that should be included along the path:

*
!.vim
!.vim/snippets
!.vim/snippets/*
!.profile
!.vimrc

So this would include the .vim dir and the snippets directory but only the files (/*) in the snippets dir.



来源:https://stackoverflow.com/questions/11633974/how-to-gitignore-everything-except-hidden-subdir

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