10
votes

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.

1
@Idan Adar -- just an FYI, regarding the stackoverflow.com/questions/tagged/worklight-adapters tag, I've had to go through a number of your previous tag wiki suggestions and add sources for heavily plagiarized text. Per meta.stackoverflow.com/questions/256436/… and numerous other Meta links, tag wikis need to have a source attribution if heavily copy-and-pasted. See stackoverflow.com/review/suggested-edits/6357996 for a good example. - LittleBobbyTables - Au Revoir
@LittleBobbyTables No problem. I'll add a link to our website... It's hardly plagiarized. :) - Idan Adar
@LittleBobbyTables, source added. - Idan Adar
Great Idan... good luck. - Idan Gozlan

1 Answers

20
votes

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