Git会删除空文件夹吗? [英] Does Git delete empty folders?

查看:519
本文介绍了Git会删除空文件夹吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经提交并将一个项目推送到我的GitHub帐户。
$ b 该项目包含以下部分文件结构:

 服务器
|
--- conf
|
-----一些文件
|
--- java
|
--- lib

java和lib文件夹为空。

当从GitHub下载我的项目时,生成的zip文件不包含java和lib文件夹。



Git是否删除空文件夹?

我使用Atlassian的SourceTree作为我的Git客户端。

解决方案

Git不会删除空文件夹; Git无法首先跟踪空文件夹(或任何类型的文件夹)。 Git只跟踪文件,这些文件夹是偶然的。 Git只在磁盘上创建文件夹以保存文件;没有文件的文件夹在Git的世界视图中不存在。



如果您想在Git存储库中保留一个空白文件夹,那么惯例是向该目录添加隐藏的空文件,例如 /java/.gitkeep


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.

解决方案

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

这篇关于Git会删除空文件夹吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆