1

I have following in .gitignore:

wordpress/*
!wordpress/wp-content/themes/my-theme/
!wordpress/wp-content/themes/my-theme/*

But when I do git status it's not seeing the untracked files.

What did I do wrong?

Guerrilla
  • 13,375
  • 31
  • 109
  • 210
  • [Documentation](https://git-scm.com/docs/gitignore#_pattern_format): *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.* – user4003407 Jul 06 '19 at 10:33
  • Is there any way to include the sub dir without the parent dir? – Guerrilla Jul 06 '19 at 10:34
  • No. You need to include all intermediate directories in path. – user4003407 Jul 06 '19 at 10:47

1 Answers1

0

Based on the example in the docs, I believe you want something like

!/wordpress
/wordpress/*
!/wordpress/..../

However, my preferred solution is to add files I want to tracked. I would do in ignore (either .git/info/exclude for just you or .gitignore for everyone):

/wordpress/*

And then run

git add -N path/to/files/to/track
D. Ben Knoble
  • 4,273
  • 1
  • 20
  • 38