首页 > 其他 > 详细

记一次Git提交报错的问题

时间:2019-10-14 01:17:43      阅读:101      评论:0      收藏:0      [点我收藏+]

通常代码版本控制的步骤是:

  • 在代码版本控制平台新建一个仓库
  • clone远程仓库到本地
  • 开始编码,然后是一系列add,commit,push

    我的步骤是:

  • 在远程代码版本管理平台新建一个仓库
  • 在本地新建一个项目
  • 通过git remote add添加远程仓库
  • 然后add, commit, push
    但是commit时就报错了:
error: failed to push some refs to ....
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.

这说明此时两个仓库并没有建立关联,两个仓库的代码没有同步。
按照提示使用git pull拉取远程代码并合并又出现如下错误:

 refusing to merge unrelated histories

意思是两个仓库的历史记录不相关。

最终解决方案:

允许不相关的历史:

git pull origin master --allow-unrelated-histories

然后再push.

记一次Git提交报错的问题

原文:https://www.cnblogs.com/wotoufahaiduo/p/11669074.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!