How to gitignore everything except hidden subdir?

2019-08-31 02:17发布

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

标签: git gitignore
1条回答
Melony?
2楼-- · 2019-08-31 02:50

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.

查看更多
登录 后发表回答