简体   繁体   中英

Git Ignore for whole folder except for sub folder?

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

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM