关于gitlab/github出现“failed to push some refs to xxx”问题

1、关于问题描述

[root@bogon autobuildwebsite]# git push -u origin master

To git@IP:xxxxx.git

! [rejected] master -> master (fetch first)

error: failed to push some refs to ‘git@IP:xxxxx.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.

百度翻译:

至git@xxxxx

![拒绝]master->master(先取)

错误:未能将某些引用推送到“git@xxxxx”

提示:更新被拒绝,因为远程包含您所做的工作,本地没有。这通常是由另一个存储库推送引起的。指向同一引用。您可能希望首先合并远程更改(例如, “git pull”),然后再按有关详细信息,请参见“git push–help”中的“关于快进的说明”。

2、问题分析

此处我使用linux服务器上传文件到gitlab远程仓库,未成功。提示我使用过另一个存储库给gitlab推送过,导致更新失败,因为linux的本地代码仓库,没有远程gitlab仓库的部分文件导致。

3、解决方案

1)方案一

①使用在linux本地git工作目录,使用 git pull --rebase origin master 命令,将远程gitlab仓库更新下载到本地

②再次使用 git push -u origin master 命令上传

但是这种办法依然报了如上错误

2)方案二

①使用 git clone git@xxxxx.git 命令,将远程仓库克隆到本地

②再次提交至本地仓库:vim xxx.txt --> git add . --> git commit -m "add xxx"

③使用 git push -u origin master 命令上传至远程仓库

ok!

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值