git 从 GitHub 中删除代码
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/443896/
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
Removing code from GitHub
提问by namin
Is there a way to entirely remove a directory and its history from GitHub?
有没有办法从 GitHub 中完全删除目录及其历史记录?
回答by Henrik Paul
If you are asking about deleting a project from GitHub, open your project, click the "Admin" tab (or browse directly to https://github.com/username/project_name/edit) and on the bottom of the page, click "Delete This Repository". It'll ask you to confirm this, and then it's gone.
如果您要从 GitHub 中删除项目,请打开您的项目,单击“管理”选项卡(或直接浏览到https://github.com/username/project_name/edit),然后在页面底部单击“删除此存储库”。它会要求您确认这一点,然后它就消失了。
If you just want to erase a part of your repository, you need to do it to your git repository and push it to GitHub.
如果您只想擦除存储库的一部分,则需要将其执行到您的 git 存储库并将其推送到 GitHub。
GitHub has written a howto about thisin their FAQ. I Haven't tried this myself, so I can't guide you further, but you probably can manage this yourself here on.
GitHub在他们的 FAQ 中写了一个关于这个的方法。我自己还没有尝试过,所以我不能进一步指导你,但你可能可以在这里自己管理。
In either case, this, naturally, doesn't delete any third party pulls – if someone has pulled the repository before you deleted it, it's out, without you being able to do much about it (other than trying the "pretty please"-technique).
在任何一种情况下,这自然不会删除任何第三方拉取 – 如果有人在您删除它之前拉取了存储库,那么它就出来了,而您对此无能为力(除了尝试“非常请”-技术)。
回答by Baishampayan Ghose
To selectively delete a file or directory (and all its associated history), you can use git filter-branch
.
要有选择地删除文件或目录(及其所有相关历史记录),您可以使用git filter-branch
.
This is very useful when you want to completely delete files checked into the repository by mistake.
当您想完全删除错误签入存储库的文件时,这非常有用。
The syntax is simple:
语法很简单:
git filter-branch --tree-filter 'rm -f filename' HEAD
More info on the man page.
手册页上的更多信息。
回答by AnonDCX
This is the easiest way the deletes a directory from your GitHub repo but not local system:
这是从 GitHub 存储库而不是本地系统中删除目录的最简单方法:
git rm -r --cached FolderName
git commit -m "Removed folder from repository"
git push origin master
回答by GEOCHET
Go to the edit tab; there's a delete link at the bottom of the page.
转到编辑选项卡;页面底部有一个删除链接。