遇到报错"error: failed to push some refs to"的解决办法

本地创建了代码库,github或gitlab上面也创建了仓库,但是在本地使用push,pull命令都没有用,提示错误

错误代码:

#git push -u origin master
To git@10.0.0.200:guojun/games.git
! [rejected] master -> master (fetch first)
error: failed to push some refs to 'git@10.0.0.200:guojun/games.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 merge the remote changes (e.g.,
hint: 'git pull') before pushing again.
hint: See the 'Note about fast-forwards' in 'git push --help' for details.

原因:github或者gitlab仓库里面的README文件没有拷贝到本地仓库来,导致本地无法push

解决办法:

需先对本地和远程仓库进行整理合并

执行命令:#git pull --rebase origin master
remote: Counting objects: 3, done.
remote: Total 3 (delta 0), reused 0 (delta 0)
Unpacking objects: 100% (3/3), done.
From 10.0.0.200:guojun/games

  • branch master -> FETCH_HEAD
    First, rewinding head to replay your work on top of it...
    Applying: add README
    Using index info to reconstruct a base tree...
    Falling back to patching base and 3-way merge...

最后再执行push或者pull 命令# git push -u origin master
Counting objects: 3, done.
Compressing objects: 100% (2/2), done.
Writing objects: 100% (2/2), 251 bytes | 0 bytes/s, done.
Total 2 (delta 0), reused 0 (delta 0)
To git@10.0.0.200:guojun/games.git
cf302ef..fb17a2a master -> master
Branch master set up to track remote branch master from origin.
成功上传代码到github或gitlab仓库,ok!

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值