0

I need everything to be ignored except the /wp-content/themes/spk7sy folder itself and everything that is in it.

I wrote this:

/*
!/wp-content/themes/spk7sy/

But for some reason all the files are not ignored.

Am I doing something wrong?

1 Answers1

0

This is a little more complex

  • So first you ignore all with *
  • But not wp-content so !wp-content/
  • Then you want to ignore all in wp-content so wp-content/*
  • etc..
*
!wp-content/
wp-content/*
!wp-content/themes/
wp-content/themes/*
!wp-content/themes/spk7sy
!wp-content/themes/spk7sy/*
Ôrel
  • 7,044
  • 3
  • 27
  • 46
  • For some reason it doesn't work :( – Sanzhar Abdurahmanov Jul 18 '21 at 22:56
  • As if git does not count with gitignore at all – Sanzhar Abdurahmanov Jul 18 '21 at 22:58
  • you need a first file commited into the directory – Ôrel Jul 18 '21 at 23:12
  • I don't understand, can you explain? – Sanzhar Abdurahmanov Jul 18 '21 at 23:38
  • Consider using `/*` for the top entry to avoid having to un-ignore anything in a subdirectory of the un-ignored path. – torek Jul 19 '21 at 02:11
  • @torek this will not work all files inside `wp-content/` will be seen whereas only themes dir should be not ignored – Ôrel Jul 19 '21 at 07:46
  • `/**` should work – Ôrel Jul 19 '21 at 07:48
  • @Ôrel: The `/*` will ignore all files and directories at the top level. The `!wp-content/` will cause `wp-content/` itself to be scanned despite this. Then the `wp-content/*` will cause all files and directories at that level to be ignored, except that the `!wp-content/themes/` entry will cause the `themes` sub-directory to be scanned. Then the `wp-content/themes/*` will cause all files and directories at *this* level to be ignored, except that the one `spk7sy` entry (file or directory) will not be ignored: if it is a directory, it will be scanned. Then `!wp-content/themes/spk7sy/*` applies. – torek Jul 19 '21 at 14:34
  • The key to my comment is this: `*` means everything at *all levels*, but `/*` and `dir/*` means *everything at the top level* and *everything in `dir/`* respectively. That's because an entry with a leading or embedded slash applies only to names *at that level*, while an entry with no slash or only a trailing slash applies to names at *that level or any sub-level*. – torek Jul 19 '21 at 14:36