Search code examples
gitgitignore

.gitignore setup for directories


I`ve the following directory structure and i want to add the directories "public" and "brand" to git, but no other subdirectories of /app/:

/app
--.gitignore
--/public
----.gitkeep
----/brand
------.gitkeep

The /app/.gitignore file looks as follows:

*
!public/.gitkeep
!public/brand/.gitkeep
!.gitignore

However, only the "public" directory is added to git but not the .gitkeep files nor the directory "brand". Do you have an idea what´s wrong with the .gitignore file?


Solution

  • Thanks for your inputs! Here´s the solution that works for me now:

    *
    !public/
    !public/**/
    !public/**/.gitkeep