我知道如果我想忽略不想推送到 Github 的文件夹。我可以.gitignore用来忽略它。
现在我的情况是我已经将文件夹推送到 Github,现在我希望我可以忽略它并在 Github 上删除它,但仍然希望文件夹在本地。
我怎样才能实现它?
似乎git rm--cached的选项就是你想要的。
git rm --cached fileToDelete
git commit master
git push origin master
Now add the file to .gitignore
虽然没有测试。
为了让您从Github中删除文件夹或文件,但不从您的计算机中删除,请按以下顺序使用此命令
name-of-the-folder"insert your comment inside this quotation marks"如果你有几个branches你可以做
masterbranchName例子
git rm -r --cached .vscodegit commit -m "removed the .vscode folder"git push origin