当前位置:   首页安装配置Git 删除远程主机文件同时保留本地文件实例详解

Git 删除远程主机文件同时保留本地文件实例详解

发布日期:2022-02-22 11:52 | 文章来源:脚本之家

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

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

联系我们
关于使用场景和技术架构的更多咨询,请联系我们的销售和技术支持团队。
Yingsoo Host

在线
客服

在线客服:7*24小时在线

客服
热线

400-630-3752
7*24小时客服服务热线

关注
微信

关注官方微信
顶部