Git 更新推送远程库报错:failed to push some refs to ‘XXXX.git‘

前言

注意:不是首次提交到远程仓库(Gitee码云),可当作我是更新代码需求。

当我改完代码并提交到本地仓库后,执行 git push 推送更新到远程仓库时,直接报错。

完整报错

Git 更新推送远程库报错:failed to push some refs to ‘XXXX.git‘_第1张图片

# 注意:远程库地址是我的(你的肯定和我不一样)
# [email protected]:wangjiabin-x/applets.git

To gitee.com:wangjiabin-x/applets.git
 ! [rejected]        master -> master (fetch first)
error: failed to push some refs to '[email protected]:wangjiabin-x/applets.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.

直接翻译英文:

到gitee.com网站:王家斌-x/小程序.git 
! [拒绝]主机->主机(先获取)
错误:无法将某些引用推送到'[email protected]:王家斌-x/小程序.git' 
提示:更新被拒绝,因为远程包含您所做的工作 
提示:本地没有。这通常是由另一个存储库推送引起的 
提示:对于同一个ref。您可能需要首先集成远程更改 
提示:(例如,“git pull…”)然后再推。
提示:有关详细信息,请参阅“git push--help”中的“关于快速前进的说明”。 

解决

直接按照提示,键入以下命令(请注意分支):

git pull --rebase origin master 

然后再正常提交:

git push

成功:
Git 更新推送远程库报错:failed to push some refs to ‘XXXX.git‘_第2张图片

你可能感兴趣的:(+,Git)