The author is misusing .gitkeep. I use it to keep source code folders that don’t contain any code yet, but whose structure is already defined.
The author is misusing .gitkeep. I use it to keep source code folders that don’t contain any code yet, but whose structure is already defined.
Truly, what purpose does this serve? Defining a hierarchy without using is injecting immediate debt. Just introduce it when stuff goes there! If you really insist then at least put something in the folder. It doesn't take much effort to make the change at least a tiny bit meaningful.
Better yet just do the work. If you want make a commit in a branch that's destined to be squashed or something, sure, but keep it away from the shared history and certainly remove it when it's not needed anymore.
I play around with ComfyUI on my computer to make silly images.
To manually install it, you must clone the repo. Then you have to download models into the right place. Where's the right place? Well, there's an empty directory called models. They go in there.
IMO that's an effective use of gitkeep.
It's not.
Is infinitely better.It could be better sure. In fact I think they use a file called PUT_MODELS_HERE not gitkeep
https://github.com/Comfy-Org/ComfyUI/blob/master/models/diff...
But in any case, that instruction was already in the readme as well.
> Truly, what purpose does this serve?
The simplest answer is that sometimes other existing software that I need to use treats an empty directory (or, hopefully, a directory containing just an irrelevant file like .gitkeep) differently from an absent directory, and I want that software to behave in the first way instead of the second.
A more thorough answer would be: Filesystems can represent empty directories, so a technology that supports versioned filesystems should be able to as well. And if that technology can't quite support fully versioned filesystems -- perhaps because it was never designed with that goal in mind -- but can nevertheless support them well enough to cover a huge number of use cases that people actually have, then massaging it a bit to handle those rough edges still makes sense.
Legitimately asking, please share the name of software that expects/requires an empty directory and interprets .gitkeep in this way, but chokes on a README file.
Many filesystems cannot represent empty directories. Many archive formats also do not. I don't think this a problem in practice. I find this argument extremely weak.
> Many filesystems cannot represent empty directories.
Like which ones? And how does mkdir(1) work on such filesystems?
> please share the name of software that expects/requires an empty directory and interprets .gitkeep in this way, but chokes on a README file.
Every mail server since postfix supports Maildir, in which every email is a file in one of 3 subdirectories (tmp, new or cur) of a user directory. If there's no jbloggs/tmp dir, postfix will think user jbloggs does not exist. So if you want to take a restorable snapshot of this with git, there needs to be a file there. I don't know if jbloggs/tmp/README would cause a problem, because I don't know how postfix will treat the presence of a file with a name that violates its expected syntax (which includes a timestamp and other metadata), but what I do know is that, after running `git clone any-repo`, I can safely delete every .gitkeep file to restore the system to its original state without having to understand that repo in detail -- while I cannot safely delete every README file. That's because the commonly understood semantics of .gitkeep is "I exist solely to shoehorn this empty dir into git", which does not apply to other files.
> Many filesystems cannot represent empty directories
Your turn -- name one.
You can rename `.gitkeep` to `.gitignore` and both be happy in that case.