简体   繁体   中英

How to gitignore everything except hidden subdir?

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

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM