How to ignore all files, but not sub-folders
I don’t want to push any files, but only all the folders in git.
I have tried the following in my .gitignore file, but it is not working:
# Ignore everything in this directory /* # Except for directories !/*/
My folder structure is,
/project/uploads -->thumbnails -->original -->croped
I need all the sub folders to go and neither files inside this “uploads” folder nor files in any other subfolders.
2 Solutions collect form web for “How to ignore all files, but not sub-folders”
Git does only track files. If you ignore all of them git has nothing to track. A possible solution is to add a
.gitignore to each directory. You can create all the subfolders, add a
.gitignore to each of them.
This will then ignore all the files, but your gitignore files in the new directories.
You are almost there:
There was just one / too much.
With this you can ignore all files but not the (non-empty) directories.