有時候會想把github上的文件刪除,但是本地倉庫裏的文件想保留下來該怎麼辦,只要用三條命令就能完成了
git rm --cached filename/-r directory
git commit "xxxx"
git push
1.刪除github文件,本地保留
git rm --cached test.
txt
git commit -m "delete file"
git push
此時github上已經不存在了
2.刪除遠程code 文件夾,本地保留
一定要注意,刪除文件夾要使用-r 參數
git rm --cached -r code
git commit -m "delete directory"
git push