Does Git delete empty folders? [duplicate]

三世轮回 提交于 2019-12-05 19:24:51

问题


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:


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



来源:https://stackoverflow.com/questions/25376342/does-git-delete-empty-folders

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!