I'm well aware that git doesn't work on empty directories (one of the more popular git questions here), but I'm asking if there's a particular justification or rationale (official if possible) in not tracking directories.
I'm asking because directories, in some cases, can have meaningful metadata by themselves. For example, the file mode of a directory can be important if sticky modes are being used. The mere fact that a directory is empty may be important for an application.
There is no official rationale. The Git FAQ simply states:
nobody competent enough to make the change to allow empty directories has cared enough about this situation to remedy it
Git tracks content, folders/directories are not content. Although you are right some metadata could be interesting for you. In such a case it's recommended to add a .gitignore
file or some other meaningless file to the directory in order to provide a content that git will recognise.
See How can I add an empty directory to a Git repository?
It's just the way Git was designed to work.
In some web projects I used to do I needed a log directory for my php which was of course also ignoring the .log files, so in essence I had an empty log directory which was required for Apache to run correctly due to my vhost settings.
In this case I added a readme.txt with nothing inside.
I'm sure you've already come across this answer on the other thread, still worth a link: https://stackoverflow.com/a/115992/662605
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With