0

Currently I have this folder

/public/images

Where all images are being stored

But I have this 1 sub folder inside of images folder named as mycta

It is possible to ignore all files inside of /public/images

except for this directory /public/images/mycta?

As of now I have this /public/images in my gitignore file

Pablo
  • 1,357
  • 1
  • 11
  • 40
  • 1
    Does this answer your question? [Exceptions in .gitignore](https://stackoverflow.com/questions/2415873/exceptions-in-gitignore) – Daemon Painter Jun 25 '20 at 09:19

1 Answers1

2

You can add a negative ignore pattern to your .gitignore file using a ! as follows:

.gitignore

/public/images/*
!/public/images/mycta

But note that instead of ignoring the whole parent directory you must ignore the contents, adding a * to that line, because as man gitignore says re !:

It is not possible to re-include a file if a parent directory of that file is excluded.

rodrigo
  • 94,151
  • 12
  • 143
  • 190