如何从 Git 中的远程存储库中删除已删除的文件夹?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/4074056/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to remove deleted folder from remote repository in Git?
提问by Jimmy
i deleted a folder from my local Git repository then i committed and pushed the changes to the remote repository, the files are deleted but the folder and the sub folder are still there. How could i remove the empty folder from the remote repository?
我从本地 Git 存储库中删除了一个文件夹,然后我提交并将更改推送到远程存储库,文件被删除但文件夹和子文件夹仍然存在。如何从远程存储库中删除空文件夹?
采纳答案by Ben Hymanson
Git doesn't actually store directories. It just makes directories wherever it needs them to hold the files that are in the repository. If a new clone still creates those directories, make sure you don't have files you can't see (like .gitignore) present.
Git 实际上并不存储目录。它只是在需要的地方创建目录来保存存储库中的文件。如果新的克隆仍然创建这些目录,请确保您没有看不到的文件(如 .gitignore)。
回答by brycemcd
You can force git to quit tracking a local file by calling:
您可以通过调用强制 git 退出跟踪本地文件:
git rm file.txt #warning, this also deletes the file from your filesystem
git rm file.txt #warning, this also deletes the file from your filesystem
You can delete an entire directory (and it's contents) by calling:
您可以通过调用删除整个目录(及其内容):
git rm -rf directory
git rm -rf directory