Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Does Git delete empty folders? [duplicate]

I've committed and pushed a project to my GitHub account.

This project contained the following partial file structure:

server 
|
--- conf
|
----- some files 
|
--- java
|
--- lib

The java and lib folders are empty.
When downloading my project from GitHub, the resulting zip did not contain the java and lib folders.

Does Git delete empty folders?
I am using Atlassian's SourceTree as my Git client.

like image 852
Idan Adar Avatar asked Aug 19 '14 05:08

Idan Adar


1 Answers

Git doesn't delete empty folders; Git cannot track empty folders (or any kind of folder) in the first place. Git only tracks files, the folders are incidental. Git only creates folders on disk in order to house files; a folder with no files in it does not exist in Git's world-view.

If you want to keep an "empty" folder in your Git repository, the convention is to add a hidden empty file to that directory, such as /java/.gitkeep

like image 138
meagar Avatar answered Sep 29 '22 05:09

meagar