Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Git ignore jpg in all directories besides one

I want to modify my .gitignore so I can ignore all .jpg files which aren't in /public/assets/images.

I have tried the following:

(!/public/assets/images/)!*.jpg

/public/assets/images/!*.jpg

However besides those two I am not sure what else to try.

like image 634
James Monger Avatar asked Sep 19 '25 08:09

James Monger


1 Answers

Try ignoring all jpg files, then explicitly unignoring /public/assets/images:

**/*.jpg
!/public/assets/images/*.jpg

The following answers explore this tangentially, and may be useful:

  • How do I tell Git to ignore everything except a subdirectory?
  • gitignore all files of extension in directory
like image 170
roelofs Avatar answered Sep 21 '25 15:09

roelofs