You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Git提交与推送地址不匹配求助:推送指向错误远程仓库

问题原因及解决步骤

核心原因

  • 你的本地仓库已配置了名为origin的远程仓库,且它指向的是旧仓库地址https://github.com/beautybird/Full-Flutter-app-Parrallex-GoRouter-Supabase.git,而非你要推送的新仓库。这就是执行git remote add origin时提示"remote origin already exists",且推送会指向错误地址的原因。
  • 推送被拒绝是因为旧远程仓库包含你本地没有的提交记录,Git不允许直接覆盖远程变更,要求你先拉取合并。

解决步骤

  1. 确认当前远程仓库配置
    执行命令查看已配置的远程仓库地址:

    git remote -v
    

    你会看到origin对应的是旧仓库的URL。

  2. 更新origin指向新仓库
    无需删除旧的origin,直接更新其地址即可:

    git remote set-url origin https://github.com/beautybird/Flutter-App-structure.git
    
  3. 验证更新结果
    再次执行git remote -v,确认origin已指向新仓库地址。

  4. 推送代码到新仓库
    执行推送命令:

    git push -u origin master
    

    若新仓库为空,推送会直接成功。若新仓库已有初始文件(如README),需先拉取远程内容并合并:

    git pull origin master --allow-unrelated-histories
    git push -u origin master
    

内容的提问来源于stack exchange,提问作者Mohd

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.18 16:29:52