关于git的使用和一些报错处理

用法:

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

 

错误:
1. Updates were rejected because the tip of your current branch is behind

有如下几种解决方法:

1.使用强制push的方法:

$ git push -u origin master -f

这样会使远程修改丢失,一般是不可取的,尤其是多人协作开发的时候。

2.push前先将远程repository修改pull下来

$ git pull origin master

$ git push -u origin master

3.若不想merge远程和本地修改,可以先创建新的分支:

$ git branch [name]

然后push

$ git push -u origin [name]

转载于:https://www.cnblogs.com/lcglcglcglcglcg/p/11087387.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值