This is my folder structure:
data/
.gitignore
uploads/
.gitignore
I would like to commit the folders but not the files inside them.
So I add a .gitignore files in every folder with the following content:
# Ignore everything in this directory
*
# Except this file
!.gitignore
The problem is that *
matches also on directories so git tracks only data/.gitignore
Please don't misuse .gitignore
files. Better stick to default ways to go on this, so later developers can quickly get into your project.
.gitkeep
file in the folders that you want to commit without the filesExclude the folders, but not the .gitkeep
from your main .gitignore
file.
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.