Chanrian7 2024-03-16 02:41 采纳率: 98.6%
浏览 26
已结题

idea的代码修改后push到gitee仓库报错push rejected

idea的项目连接了一个现有的gitee仓库(该仓库不是空白的仓库,之前有老项目的代码push上去。因为idea误操作导致老项目许多模块丢失,因此才重新创建新项目,连接原有的同一个gitee仓库),新项目push失败报错push rejected 具体如下:

02:28:19.482: [ChatGPT] git -c core.quotepath=false -c log.showSignature=false push --progress --porcelain origin refs/heads/master:master
error: failed to push some refs to 'gitee.com:chanrian/chat-gpt.git'
To gitee.com:chanrian/chat-gpt.git
!    refs/heads/master:refs/heads/master    [rejected] (non-fast-forward)
hint: Updates were rejected because the tip of your current branch is behind
hint: its remote counterpart. Integrate the remote changes (e.g.
Done
hint: 'git pull ...') before pushing again.
hint: See the 'Note about fast-forwards' in 'git push --help' for details.
02:28:43.025: [ChatGPT] git -c core.quotepath=false -c log.showSignature=false push --progress --porcelain origin refs/heads/master:master
error: failed to push some refs to 'gitee.com:chanrian/chat-gpt.git'
To gitee.com:chanrian/chat-gpt.git
hint: Updates were rejected because the tip of your current branch is behind
hint: its remote counterpart. Integrate the remote changes (e.g.
!    refs/heads/master:refs/heads/master    [rejected] (non-fast-forward)
hint: 'git pull ...') before pushing again.
Done
hint: See the 'Note about fast-forwards' in 'git push --help' for details.

查了一些资料有的说是git冲突问题,于是git remote -v查看连接的仓库,发现出来有两个,这样是正常的吗?

img

也有一些教程说要先pull拉取再提交,尝试过后也不行,如下:

D:\java\chatGPT_worksplace\ChatGPT> git pull origin master --allow-unrelated-histories
From gitee.com:chanrian/chat-gpt
 * branch            master     -> FETCH_HEAD
error: The following untracked working tree files would be overwritten by merge:
        .idea/.gitignore
        .idea/compiler.xml
      //这里中间省略类似的文件路径
        .idea/libraries/Maven__org_springframework_spring_web_6_1_4.xml
        .idea/libraries/Mav
Aborting
Merge with strategy ort failed.

D:\java\chatGPT_worksplace\ChatGPT>git push origin master
To gitee.com:chanrian/chat-gpt.git
 ! [rejected]        master -> master (non-fast-forward)                    
error: failed to push some refs to 'gitee.com:chanrian/chat-gpt.git'        
hint: Updates were rejected because the tip of your current branch is behind
hint: its remote counterpart. Integrate the remote changes (e.g.            
hint: 'git pull ...') before pushing again.                                 
hint: See the 'Note about fast-forwards' in 'git push --help' for details.  

请问这是什么问题呢,应该如何才能成功push到gitee仓库上呢

  • 写回答

2条回答 默认 最新

  • 关注

    Chanrian7 上午好☀️☀️☀️️
    本答案参考ChatGPT-3.5

    根据你的描述,你在将修改后的代码push到gitee仓库时遇到了错误。错误信息显示当前分支的tip落后于远程分支,导致无法push成功。

    错误信息中给出了解决方案的提示,可以尝试以下方法来解决该问题:

    1. 拉取远程分支并合并

      • 执行git pull origin master --allow-unrelated-histories命令,将远程分支的代码拉取到本地,并允许不相关的历史记录合并。
      • 如果出现冲突,需要手动解决冲突,然后提交合并结果。
      • 执行git push origin master命令,将合并后的代码推送到远程仓库。
    2. 强制推送到远程分支

      • 如果你确认远程分支的代码不再需要,可以执行强制推送操作。
      • 执行git push -f origin master命令,将本地分支的代码强制推送到远程分支。
      • 注意:使用强制推送时要小心,因为它将覆盖远程分支的所有更改。

    请尝试以上两种解决方案,并根据你的需求选择合适的解决方案。如果问题仍然存在,请提供更多信息,以便我们可以帮助你进一步解决问题。

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

问题事件

  • 系统已结题 3月25日
  • 已采纳回答 3月17日
  • 创建了问题 3月16日

悬赏问题

  • ¥15 35114 SVAC视频验签的问题
  • ¥15 impedancepy
  • ¥15 在虚拟机环境下完成以下,要求截图!
  • ¥15 求往届大挑得奖作品(ppt…)
  • ¥15 如何在vue.config.js中读取到public文件夹下window.APP_CONFIG.API_BASE_URL的值
  • ¥50 浦育平台scratch图形化编程
  • ¥20 求这个的原理图 只要原理图
  • ¥15 vue2项目中,如何配置环境,可以在打完包之后修改请求的服务器地址
  • ¥20 微信的店铺小程序如何修改背景图
  • ¥15 UE5.1局部变量对蓝图不可见