Ignore Directory Contents In Git While Keeping The Directory In The Repo

May - 2022

If you want to keep empty directories inside the version control, the standard way to do that is to touch a ".gitignore" file to create an empty file with that name in the structure.

If you've got a tree that has sub directories, you only need to add the .gitignore file to the bottom most one. Since it has to be there, the rest of the tree above it must be included also.

This allows itself to stay in the repo

Code for .gitignore to store empty dir


Need to see how this would work on export if you tell the export command to skip .gitignore files. Hopefully, that'll work.

tags: ignore, directory