[转]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