How do I ignore all files in a project except two subdirectories? I don't want to include all of Wordpress in Git, but I do want to include the customized themes. I have two sibling directories so I don't want two separate Git projects either.
.gitignore
src/
!src/wp-content/themes/chocolat-child/
!src/wp-content/themes/theme2
It is a fresh repository initialization with no history or commits. When I check status, it is ignoring the subdirectories.
>git status
# Initial commit
# Untracked files:
# (use "git add <file>..." to include in what will be committed)
# .gitignore
# .project
# .settings/
I saw this section in the documentation, but there has to be a workaround: http://git-scm.com/docs/gitignore
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. Put a backslash ("\") in front of the first "!" for patterns that begin with a literal "!", for example, "!important!.txt".
I saw this question, but it was due to a hidden Drupal .gitignore, so it doesn't solve my problem: Ignoring a directory...but not a subdirectory or two
version
git version 1.8.1.msysgit.1