I’ve been using Git for 9 years now, and today was the first time I knowingly encountered a file named .gitkeep
in a diff. “What’s the point of this empty file?”, I thought. Quickly realizing that the idea is to track an empty directory, I started to wonder “Why would you want to make sure a directory exists when there’s nothing to put there?” and I started seeing blog posts about preparing for future changes that will add files to the directory or making sure your team has a consistent directory structure.
Why would you use .gitkeep?
GitHub Squash Merges are a Menace
I love squash merging. I think it’s the simplest way to maintain a legible commit history on main
, a shared dev
branch, etc. It’s easy for most people to follow, and it doesn’t require you to be too Big Brained about git. GitHub even provides a convenient interface for doing this, right in the pull request UI!
But GitHub’s squash merge workflow undermines the biggest benefits of squash merges: clear, simple, atomic commit messages that explain what each commit does.
You Should Squash Merge to main
Every so often I’ll see a meme on Twitter like:
and it makes me so mad. For good reason! OSS project repositories that support merge commits to main are usually littered with useless comments like: “Merge change from $USER, $PR”. It makes the commit history on main utterly useless and you get to check the various feature branches in a never ending snake of commits to find out what the hell changed.