Git如何刪除遠程服務器文件同時保留本地文件

[轉]Git如何刪除遠程服務器文件同時保留本地文件

轉自http://xfenglin.com/a/12011088250.html?ref=myread

在上傳工程到git時,有時候會把本地的一些eclipse配置文件傳到服務器上,這時先刪除本地文件,再同步服務器,顯然不合理,git提供了一個好的解決辦法,可以直接刪除服務器文件,同時不影響本地文件,命令如下:

git rm --cached filename/-r directory
git commit "xxxx"
git push

1.刪除服務器文件,本地保留

git rm --cached useless.log
git commit -m "remove file remote respository"
git push 

2.刪除遠程useless文件夾,本地保留
需要注意:刪文件夾需要使用 -r 參數

git rm --cached -r useless
git commit -m 'remove directory from remote respository'
git push
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章