Git 如何刪除遠程服務器文件同時保留本地文件
在上傳工程到git上時,有時候會把本地的一些eclipse配置文件傳到服務器上,這時你先刪除本地,再同步服務器,顯然是不合理的。git提供了一個好的解決方法,可以直接刪除服務器文件,同時不影響本地文件,命令如下
1
2
3
|
git rm --cached filename /-r directory git commit "xxxx" git push |
1.刪除服務器文件,本地保留
1
2
3
|
git rm --cached useless.log git commit -m "remove file from remote repository" git push |
此時github上已經(jīng)不存在了
2.刪除遠程useless 文件夾,本地保留
一定要注意,刪除文件夾要使用-r 參數(shù)
1
2
3
|
git rm --cached -r useless git commit -m "remove directory from remote repository" git push |
感謝閱讀,希望能幫助到大家,謝謝大家對本站的支持!
原文鏈接:http://xfenglin.com/a/12011088250.html