Git 删除远程服务器文件同时保留本地文件实例详解

(编辑:jimmy 日期: 2024/9/22 浏览:2)

Git 如何删除远程服务器文件同时保留本地文件

在上传工程到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 from remote repository"
git push

此时github上已经不存在了

2.删除远程useless 文件夹,本地保留

一定要注意,删除文件夹要使用-r 参数

git rm --cached -r useless
git commit -m "remove directory from remote repository"
git push

感谢阅读,希望能帮助到大家,谢谢大家对本站的支持!

一句话新闻
Windows上运行安卓你用过了吗
在去年的5月23日,借助Intel Bridge Technology以及Intel Celadon两项技术的驱动,Intel为PC用户带来了Android On Windows(AOW)平台,并携手国内软件公司腾讯共同推出了腾讯应用宝电脑版,将Windows与安卓两大生态进行了融合,PC的使用体验随即被带入到了一个全新的阶段。