如何使用 Eclipse 从 GitHub 中删除特定目录

How to remove a specific directory from GitHub using Eclipse

我已经四处查看了几天,现在试图弄清楚这一点,因为我们的 .gitignore 即使它列出了 /bin/ 文件夹,它仍然不断地提交整个文件夹并且它变得烦人。

现在我们的 GitHub 存储库的 /bin/ 文件夹中有一大堆垃圾,我不知道如何删除它。我试过查看其他人的示例,但他们一直在谈论我在 eclipse 中没有的 shell 命令(或者至少不知道如何访问)

不幸的是,如果一个文件已经提交到 GitHub,git 将继续对该文件进行版本控制。

这意味着如果我提交整个 bin/ 然后将其添加到 .gitignore,这些文件仍将保留在 GitHub 中。而且,如果 bin/ 中的这些文件发生更改,它们也会被推送到提交中,因为它们是版本化的。

幸运的是,您可以从 GitHub 中完全删除文件和目录。不过,您需要进入命令行 运行ning git。如果您安装了 GitHub 应用程序,那可能意味着您有 git.

在 Windows 中打开命令提示符或在 Mac 中打开终端 OS。

导航到目录(即 cd ~/Workspace/Project)并运行以下内容:

git rm bin/* -f
git commit --amend
git push -f

这应该有效。查看 this article on the GitHub,其中也概述了该过程。

希望对您有所帮助!

Disclaimer: always make sure you do your research before working with git. If you have various branches / other complicated stuff going on, this process might be different