Frequently asked questions around Git and Version Control.
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.
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.
- Check out the chapter Starting with an Unversioned Project in our free online book
- More frequently asked questions about Git & version control