Reputation: 7327
I have a git repo in my home folder. I'm trying to NOT include basically the entirety of my home folder, with the exception of my .vim folder.
In my .gitignore, I have
*
!.vim
The problem is that this only adds the .vim
directory into my git repo, but not its files and its subdirectories (and its files, and its subdirectories, and so on). I'd like to have .vim
and ALL of its subfiles and subdirectories into my git repo. How do I change this .gitignore
for the desired behavior?
Upvotes: 1
Views: 688
Reputation: 1329092
If you want to exclude a folder content, you would need to exclude first folders (because of the parent directory rule):
*
!*/
Then you can exclude the .vim/
folder content:
!.vim/**
Upvotes: 2
Reputation: 165546
*
includes the current directory, so you're being bitten by this:
An optional prefix "!" which negates the pattern; any matching file excluded by a previous pattern will become included again. It is not possible to re-include a file if a parent directory of that file is excluded. Git doesn't list excluded directories for performance reasons, so any patterns on contained files have no effect, no matter where they are defined.
I don't know of any way to say "everything in the top level directory except the top level directory".
If you only want to put .vim
into Git, you should put your Git repository in .vim
.
Upvotes: 1