git 会忽略空文件夹吗?
我创建了一个 Android 项目,将其添加到我的 git 存储库中,提交并将我的克隆推送到 master。后来我尝试检查该项目,Eclipse 抱怨缺少 src 文件夹。我检查了我的存储库,主存储库和 src 文件夹丢失了(我确定它们在我创建项目时就在那里)。那么有人可以解释这里发生了什么吗?我对 git 很陌生,所以也许我错过了什么?
I created an Android project, added it to my git repo, comitted and pushed my clone to the master. Later I tried checking out the project and Eclipse complained about missing src folders. I checked my repo and the master repo and the src folders are missing (Im sure they were there when I created the project). So can someone explain what happened here? Im new to git so maybe I missed something?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(6)
Git 不会忽略空目录。它忽略所有目录。在 Git 中,目录仅通过其内容隐式存在。空目录没有任何内容,因此它们不存在。
或者换句话说:Git 是一个内容跟踪器。空目录没有内容。
Git doesn't ignore empty directories. It ignores all directories. In Git, directories exist only implicitly, through their contents. Empty directories have no contents, therefore they don't exist.
Or to put it another way: Git is a content tracker. Empty directories are not content.
是的,git 会忽略空文件夹。
您可以将空的
.gitignore
或.gitkeep
文件添加到您想要包含的任何文件夹中。Yes, git ignores empty folders.
You can add an empty
.gitignore
or.gitkeep
file to any folders you want included.Git 跟踪内容而不是文件。
此处提出了一个解决方案。
Git tracks content not files.
A solution is proposed here.
git 会忽略所有目录,无论它们是否为空。
当文件需要存在于不存在的目录中时,git 将在磁盘上构建树时重新创建目录。否则,不会关注目录。
git ignores all directories whether they're empty or not.
git will recreate directories when building out a tree on disk when a file needs to exist in a directory that does not. Otherwise, no attention is paid to directories.
是的,git 会忽略空文件夹,关于如何解决这个问题的一些建议是:
Yes, git ignores empty folders, some suggestions on how to solve that are:
是的,git 不会跟踪空文件夹。 在 StackOverflow 上进行完整讨论
Yes, git will not track empty folders. Find a full discussion here on StackOverflow