How can I add an empty folder to a repository?
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 .keep File
A popular solution is to simply add a file named ".keep" in the corresponding folder. You can now stage and commit this file and, as a consequence, also add the folder to version control.
Note that .keep is not a "magical" name but rather a popular convention. Also, the file doesn't serve any other purpose beyond making its containing folder visible to Git.
Tip
Become more productive with Git
Check out Tower, the Git client of choice for over 80,000 users in companies like Apple, Amazon, Google, and Microsoft.
Learn More
- Check out the chapter Starting with an Unversioned Project in our free online book
Get our popular Git Cheat Sheet for free!
You'll find the most important commands on the front and helpful best practice tips on the back. Over 100,000 developers have downloaded it to make Git a little bit easier.
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.