git问题解决方法error: failed to push some refs to

error: failed to push some refs to

To https://gitee.com/abo0527/a_taobao.git
 ! [rejected]        master -> master (fetch first)
error: failed to push some refs to 'https://gitee.com/abo0527/a_taobao.git'
hint: Updates were rejected because the remote contains work that you do
hint: not have locally. This is usually caused by another repository pushing
hint: to the same ref. You may want to first integrate the remote changes
hint: (e.g., 'git pull ...') before pushing again.
hint: See the 'Note about fast-forwards' in 'git push --help' for details.
复制代码

错误原因:在推送前没有进行本地仓库和远程服务器的同步

解决方法:

1、强推,即利用强覆盖方式用你本地的代码替代git仓库内的内容,如果远程仓库是刚建的,没有代码,可以这样操作,尽量避免这种操作方法。

git push -f
复制代码

2、先把git的东西fetch到你本地然后merge后再push

$ git fetch
$ git merge
复制代码

3、在使用的时候,git merge,又出现了以下的问题

$ git merge
fatal: refusing to merge unrelated histories
复制代码

对于这个问题。使用下面命令处理

git pull origin master --allow-unrelated-histories 
复制代码

4、然后继续git merge,依然有问题

fatal: You have not concluded your merge (MERGE_HEAD exists).
Please, commit your changes before you merge.
复制代码

这个就好处理了,是我们没有提交当前的变化, git add .,git commit -am "提交信息" 然后再来一次git merge,然后ok. 5、然后输入git pull,显示如下

Already up-to-date.
复制代码

最后再进行推送

$git push origin master 
复制代码

转载于:https://juejin.im/post/5cd901aa518825697d770f16

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值