git提交代码时报错:error: failed to push some refs to ‘https://gitee.com/xxx/xxx.git‘

1、报错如下:

error: failed to push some refs to 'https://gitee.com/xxx/xxx.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.

  

  解决办法:亲测有效,借鉴博客:https://blog.csdn.net/zhao_xin_peng/article/details/79378895

第一步执行:git pull --rebase origin master


第二步再执行语句:git push -u origin master

完美解决

  • 3
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
根据引用\[1\]的错误信息,你在执行`git push -u origin master`命令遇到了错误。错误提示是`! \[rejected\] master -> master (fetch first)`,这通常是由于远程分支包含了本地分支中不存在的提交导致的。这是多人协作开发过程中常见的问题。 根据引用\[2\]的正确解决办法,你可以先与远程仓库建立连接,使用命令`git remote add origin https://gitee.com/xxx/xxx.git`。这样就能将远程仓库克隆到本地。 另外,根据引用\[3\]的解决方法2,你可以先将远程分支上的所有文件下载到本地,使用命令`git clone https://gitee.com/xxx/xxx.git`。然后将要上传的文件放入刚刚下载的文件夹中,再使用命令`git add`、`git commit`和`git push`来上传文件。 综上所述,你可以尝试先与远程仓库建立连接,然后将远程分支上的文件下载到本地,最后将要上传的文件放入文件夹中并执行相应的git命令来解决问题。 #### 引用[.reference_title] - *1* *3* [Git Bash中出现:error: failed to push some refs to ‘https://gitee.com/xxx/xxx.git‘错误的解决方法](https://blog.csdn.net/seven__lover/article/details/122199611)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v91^insert_down28v1,239^v3^insert_chatgpt"}} ] [.reference_item] - *2* [git使用git push -u origin master提交远程仓库报错error: failed to push some refs to ‘...](https://blog.csdn.net/qq_48435252/article/details/131537027)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v91^insert_down28v1,239^v3^insert_chatgpt"}} ] [.reference_item] [ .reference_list ]
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

放学后一起去放牛啊

来了大爷,技术笔记不易求赏则个

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值