Skip to main content
Git FAQ
Frequently asked questions around Git and Version Control.
Git FAQ featured image

How Can I Add an Empty Folder to a Repository?

Short answer: Git does not track empty directories, but the standard workaround is to place a placeholder file (.gitkeep or .keep) inside the folder.

Let's start with a tiny bit of background information: Git does not care about folders - it cares about files. Therefore, if a folder is empty, Git will not offer you to add it to version control.

While there is no "standard" solution to this problem, there are a couple of different approaches to "circumvent" this behavior.

Adding a .gitkeep or .keep File

A popular solution is to add a file named .gitkeep (or .keep) to the folder. You can then stage and commit this file and, as a consequence, also add the folder to version control.

.gitkeep has become the more widely adopted convention because the .git prefix signals intent to other developers. Neither name has any special meaning to Git itself — any filename works.

Here are the commands to do this in a terminal:

mkdir logs/
touch logs/.gitkeep
git add logs/.gitkeep
git commit -m "Add logs directory"
git push origin main

Alternative: .gitignore as a Placeholder

Some teams use an empty .gitignore file instead of .gitkeep — this works identically and also gives you a ready-made place to add ignore rules for that directory later.

Learn More

About Us

As the makers of Tower, the best Git client for Mac and Windows, we help over 100,000 users in companies like Apple, Google, Amazon, Twitter, and Ebay get the most out of Git.

Just like with Tower, our mission with this platform is to help people become better professionals.

That's why we provide our guides, videos, and cheat sheets (about version control with Git and lots of other topics) for free.