简体   繁体   English

删除github中的文件夹,但不在本地

[英]Delete a folder in github, but not in local

I know that if I want to ignore folder that I don't want to push to Github.我知道如果我想忽略不想推送到 Github 的文件夹。 I could use .gitignore to ignore it.我可以使用.gitignore忽略它。

Now my situation is I had pushed the folder up to Github, now I wish I could ignore it and delete it on Github, but still want the folder in local side.现在我的情况是我已经将文件夹推送到 Github,现在我希望我可以忽略它并在 Github 上删除它,但仍然希望该文件夹在本地。

How could I achieve it?我怎么能做到呢?

It seems like the --cached option of git rm is what you want.似乎git rm--cached选项正是您想要的。

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

Not tested though.虽然没有测试。

In order for you to remove the folder or file from Github but no from you computer use this command in the following order为了让您从Github 中删除文件夹或文件,但没有从您的计算机中删除,请按以下顺序使用此命令

  1. git rm -r --cached name-of-the-folder git rm -r --cached name-of-the-folder
  2. git commit -m "insert your comment inside this quotation marks" git commit -m "insert your comment inside this quotation marks"
  3. git push origin git push 原点

in case you have several branches you can do如果你有几个branches你可以做

  • git push origin master git push origin master
  • git push origin branchName git push origin branchName

EXAMPLE例子

  1. git rm -r --cached .vscode
  2. git commit -m "removed the .vscode folder"
  3. git push origin

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM