9

我知道如果我想忽略不想推送到 Github 的文件夹。我可以.gitignore用来忽略它。

现在我的情况是我已经将文件夹推送到 Github,现在我希望我可以忽略它并在 Github 上删除它,但仍然希望文件夹在本地。

我怎样才能实现它?

4

2 回答 2

15

似乎git rm--cached的选项就是你想要的。

git rm --cached fileToDelete
git commit master
git push origin master
Now add the file to .gitignore

虽然没有测试。

于 2013-03-24T11:29:28.243 回答
1

为了让您从Github中删除文件夹或文件,但不从您的计算机中删除,请按以下顺序使用此命令

  1. git rm -r --cached name-of-the-folder
  2. git 提交 -m "insert your comment inside this quotation marks"
  3. git推送起源

如果你有几个branches你可以做

  • git推送起源 master
  • git推送起源 branchName

例子

  1. git rm -r --cached .vscode
  2. git commit -m "removed the .vscode folder"
  3. git push origin
于 2020-08-17T09:24:19.180 回答