Live data from Hacker News

Don't create .gitkeep files, use .gitignore instead (2023)

adamj.eu

1–10 of 101 posts

Re: Don't create .gitkeep files, use .gitignore instead (2023)

#3

I'm confused. Having a file gitignored doesn't stop you from committing it; AFAIK you can just touch build/.gitkeep git add build/.gitkeep git commit build/.gitkeep And that's it? There's no need to exclude anything.

The idea is that you don't want to check-in any builds.

Re: Don't create .gitkeep files, use .gitignore instead (2023)

#5
post #3

I'm confused. Having a file gitignored doesn't stop you from committing it; AFAIK you can just touch build/.gitkeep git add build/.gitkeep git commit build/.gitkeep And that's it? There's no need to exclude anything.

The idea is that you don't want to check-in any builds.

Sure, so gitignore build/ or whatever. But you don't need to unignore .gitkeep

Re: Don't create .gitkeep files, use .gitignore instead (2023)

#9
post #7

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.

Post reply on HN