Git删除目录 [英] Git remove directory

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

问题描述

我在GitHub上有一个仓库( http://github.com/hrickards/PHP-Crypto )对于一个小项目我和其他几个人正在努力。我的开发环境是Aptana Studio,我使用EGit插件,因为Aptana基本上就是Eclipse。今天,设计师将网站的HTML和CSS发送到名为img的文件夹中。以前,图像位于名为图像的文件夹中。我什么都不想,也懒得更新CSS和HTML,我只是把这些图像保存在img目录中,并提交给Git。但是,GitHub Web界面显示了img和images目录,images目录为空。我试过用 git rm -r images git rm images ,甚至<$ c来删除images目录$ c> mkdir图片; git添加图片; git rm -r images 但无论我尝试获得相同的结果:
fatal:pathspec'images'与任何文件都不匹配

有没有人有关于如何删除图像的任何建议,或者我误解Git或什么?

解决方案

Git不存储关于该目录的任何信息,只是其中的文件。所以,你不能自己添加或删除目录;如果你说 git add images ,Git将添加该目录内的所有文件(不匹配忽略列表)。



通常情况下,存在空目录的唯一方法是它实际上包含一个文件,通常是隐藏文件,如 .gitignore



你说你在GitHub上看到一个 images 目录,但是我没有看到你链接到的回购站点。你确定它在那里,而不仅仅是磁盘上的空目录吗?如果它只是磁盘上的空目录,则可以使用 rm images ;将其删除。 Git不需要知道它。


I've got a repository on GitHub (http://github.com/hrickards/PHP-Crypto) for a little project me and a couple of others are working on. My development environment is Aptana Studio, and I use the EGit plugin as Aptana is basically Eclipse underneath. Today the designer sent the HTML and CSS for the website with the images in a folder named img. Previously the images were in a folder called images. Thinking nothing of it and being too lazy to update the CSS and HTML, I simply kept the images in the img directory and commited to Git. However, the GitHub web interface shows both the img and images directories, with the images directory being empty. I've tried deleting the images directory with git rm -r images and git rm images, and even mkdir images; git add images; git rm -r images but whatever I try I get the same result: fatal: pathspec 'images' did not match any files.

Has anyone got any advice on how to remove images, or am I misunderstanding Git or something?

解决方案

Git does not store any information about the directory, just the files within it. So, you cannot add or remove directories themselves; if you say git add images, Git will add all of the files within that directory (that don't match the ignore list).

Generally, the only way for there to be an empty directory is if it actually contains a file, usually a hidden file like .gitignore.

You said that you see an images directory on GitHub, but I'm not seeing it in the repo that you linked to. Are you sure it's there, and not just an empty directory on your disk? If it's just an empty directory on your disk, you can just remove it using rm images; Git doesn't need to know about it.

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

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