Create an empty folder

suggest change

It is not possible to add and commit an empty folder in Git due to the fact that Git manages files and attaches their directory to them, which slims down commits and improves speed. To get around this, there are two methods:

Method one: .gitkeep

One hack to get around this is to use a .gitkeep file to register the folder for Git. To do this, just create the required directory and add a .gitkeep file to the folder. This file is blank and doesn’t serve any purpose other than to just register the folder. To do this in Windows (which has awkward file naming conventions) just open git bash in the directory and run the command:

$ touch .gitkeep

This command creates a blank .gitkeep file in the current directory. .gitkeep is only a convention; Git has no special handling for that name.

Method two: dummy.txt

Another hack is the same steps with dummy.txt instead of .gitkeep. It is easy to create from the Windows context menu, and you can leave a short note in it. You can also use a .gitkeep file to track the empty directory. .gitkeep is normally an empty file added so Git has something to track in that directory.

Feedback about page:

Feedback:
Optional: your email if you want me to get back to you:



Table Of Contents