Keeping track of empty folders in Git

Haneen Mahdin
1 min readApr 2, 2023

You might have noticed that git doesn’t push folders into the repository. It can only track files. It pushes a folder when there are contents in it. The folder you created might still exist in your codebase but when pushed to the remote and cloned by another developer, the folder you created might not exist at all.

This is bad news, if you’re following a strict folder structure for your codebase. Some things could break. That is where .gitkeep comes in.

What is .gitkeep?

.gitkeep file isn’t a feature of git but instead is a standward way of keeping track of folders by developers. You can still keep track of a folder even without .gitkeep but by just putting any kind of file inside the folder that’s not ignored by git.

How to push empty folders?

As said above, you don’t specifically need to use .gitkeep to push empty folders. You can create any kind of file and put them inside the directory and those changed will be pushed to the repository.

.gitkeep is just a common and standard way of doing so.

--

--

Haneen Mahdin

✶ 16, freelance design engineer and startup-founder