I'm not sure if I'm the one to blame for this or not, but the earliest reference to ".gitkeep" I can find online is my 2010 answer on Stack Overflow: https://stackoverflow.com/a/4250082/28422 If this is all my fault, I'm sorry.
Yeah... I don't think you were wrong. Having 100 tiny gitignores makes finding out why something is excluded annoying. Our policy is one root level gitgnore and gitkeeps where required. Some devs will just open the first gitignore they see and throw stuff into it. No thank you.
Don't create .gitkeep files, use .gitignore instead (2023)
71–80 of 101 posts
Re: Don't create .gitkeep files, use .gitignore instead (2023)
#72Re: Don't create .gitkeep files, use .gitignore instead (2023)
#73My preference is to use the build system to create built artifacts, and I consider the build/ directory to be a built artifact. Wrangling Git into doing the first fundamental build step is off, in my opinion. However, if you disagree, my favorite "Git keep" filename is "README.md". Why is this otherwise empty directory here, how does it fit into my source tree, how is it populated, and so forth. One of my pet peeves…
Additionally, the AI comment is ironic as well. It's like we're finally writing good documentation for the sake of agents, in a way that we should have been writing all along for other sentient consumers. It's funny to see documentation now as basically the horse instead of the cart.
Re: Don't create .gitkeep files, use .gitignore instead (2023)
#74Re: Don't create .gitkeep files, use .gitignore instead (2023)
#75Not sure why you can’t just have your build script create the build directory?
Usually, you can. But occasionally you get mildly defective tools that require some directory to exist, even though it's empty. It's easier to add a gitkeep than fix them.
Your point is valid though. It would be much preferable to include build/ in your root .gitignore so that the directory is never tracked.
Re: Don't create .gitkeep files, use .gitignore instead (2023)
#76Earlier quoted context omitted.
> 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…
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.
Like which ones? And how does mkdir(1) work on such filesystems?
Re: Don't create .gitkeep files, use .gitignore instead (2023)
#77Why did Git decide to have no means to track fully empty directories? Like, I understand that e.g. doing "git rm *" inside a directory should probably delete this directory from the repository as well (although "git rm -r dir_to_delete" exists so...) but why not have a command to explicitly force a directory to be tracked, whether it's empty or not?
Re: Don't create .gitkeep files, use .gitignore instead (2023)
#78Oh, man, I'd forgotten about these negated .gitignore patterns entirely. It actually hadn't occurred to me that they could override the behaviour of ignoring empty directories. This is potentially actually useful for me, because I have a project with test data that consists of miniature filesystem sub-trees — that should include empty directories to ensure edge cases are covered. I've been zipping them up and having…
You will have proper diff for the tree this way.
Re: Don't create .gitkeep files, use .gitignore instead (2023)
#79Why did Git decide to have no means to track fully empty directories? Like, I understand that e.g. doing "git rm *" inside a directory should probably delete this directory from the repository as well (although "git rm -r dir_to_delete" exists so...) but why not have a command to explicitly force a directory to be tracked, whether it's empty or not?
Re: Don't create .gitkeep files, use .gitignore instead (2023)
#80Arent Gitkeep files specifically for empty folders that are intended to be there? That is what I have always used them for....