Please don’t misuse .gitignore files. Better stick to default ways to go on this, so later developers can quickly get into your project.
- Add an empty
.gitkeepfile in the folders that you want to commit without the files -
Exclude the folders, but not the
.gitkeepfrom your main.gitignorefile.folder/* !folder/.gitkeep
This ignores all files in a folder, but not the .gitkeep file. Now the folder will be commited with only the .gitkeep file as content.