Don't create .gitkeep files, use .gitignore instead (2023)
51–60 of 101 posts
Re: Don't create .gitkeep files, use .gitignore instead (2023)
#52The author makes a very common mistake of not reading the very first line of the documentation for .gitignore. A gitignore file specifies intentionally untracked files that Git should ignore. Files already tracked by Git are not affected; see the NOTES below for details. You should never be putting "!.gitignore" in .gitignore. Just do `echo "*" > .gitignore; git add -f .gitignore`. Once a file is tracked any changes…
Re: Don't create .gitkeep files, use .gitignore instead (2023)
#53Not sure why you can’t just have your build script create the build directory?
Re: Don't create .gitkeep files, use .gitignore instead (2023)
#54Earlier quoted context omitted.
No. Use a .gitignore instead of .gitkeep. Instead of checking in build/.gitkeep, check in build/.gitignore.
I don't know that I like this approach. It certainly works, but it's not specifically what (people expect) a .gitignore file to be used for. That confusion isn't good: https://thecodelesscode.com/case/222 and https://thecodelesscode.com/case/223
Re: Don't create .gitkeep files, use .gitignore instead (2023)
#55Re: Don't create .gitkeep files, use .gitignore instead (2023)
#56.gitkeep is intuitive and easy to understand. Unignoring a .gitignore is not intuitive. This falls squarely into "clever optimization tricks that obscure intent and readability". Don't do things like this. It's not that hard to update a .gitignore file every now and then.
Using the actual tools built in to git directly removes steps in the process, which is always a good thing, it's documented as part of the git documentation, so you don't have to create a wiki page explaining why there is a ".gitkeep" file that git doesn't recognize itself.
Saying "It's not that hard..." is fine for projects with a few contributors but does not scale.
Re: Don't create .gitkeep files, use .gitignore instead (2023)
#57Earlier quoted context omitted.
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…
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.
echo >repo/models/README.md "this is the directory you place models in"
Is infinitely better.Re: Don't create .gitkeep files, use .gitignore instead (2023)
#58Earlier quoted context omitted.
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…
> 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…
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.
Re: Don't create .gitkeep files, use .gitignore instead (2023)
#59I'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.
Some devs will just open the first gitignore they see and throw stuff into it. No thank you.
Re: Don't create .gitkeep files, use .gitignore instead (2023)
#60Earlier quoted context omitted.
qemu: mkdir build; cd build; ../configure, some projects are like that
Why can’t the configure script do this?