Jun 25, 2020
Per Djurner

Git ignore a folder with exceptions

Usually when working with .gitignore files it's pretty straight forward, you ignore some folders and / or files and you're done. But what if you want to ignore everything inside a folder except for specific folders and files inside it?

Here's how you can do that.


As you can see the ! prefix is used here. It negates the pattern so that any matching file excluded by a previous pattern will become included again.