Git 如何刪除遠程服務器文件同時保留本地文件
在上傳工程到git上時,有時候會把本地的一些eclipse配置文件傳到服務器上,這時你先刪除本地,再同步服務器,顯然是不合理的。git提供了一個好的解決方法,可以直接刪除服務器文件,同時不影響本地文件,命令如下
git rm --cached filename/-r directorygit commit "xxxx"git push
1.刪除服務器文件,本地保留
git rm --cached useless.loggit commit -m "remove file from remote repository"git push
此時github上已經不存在了
2.刪除遠程useless 文件夾,本地保留
一定要注意,刪除文件夾要使用-r 參數
git rm --cached -r uselessgit commit -m "remove directory from remote repository"git push
感謝閱讀,希望能幫助到大家,謝謝大家對本站的支持!
新聞熱點
疑難解答
圖片精選