首页 > 其他 > 详细

Git 本地推送远程失败 non-fast-forward

时间:2020-10-05 14:35:25      阅读:36      评论:0      收藏:0      [点我收藏+]

To github.com:Yee-Q/yeexang-community.git
 ! [rejected]        dev -> dev (non-fast-forward)
error: failed to push some refs to ‘git@github.com:Yee-Q/yeexang-community.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.

错误提示如上,本地项目向远程推送时,提示远程 non-fast-forward,即时本地比远程领先,推送前必须先合并,Git 也给出提示了,要我们先 git pull


There is no tracking information for the current branch

这是因为没有指定本地分支与远程分支的关联,可以使用

git pull origin dev

如果希望一劳永逸,可以使用

git branch --set-upstream-to=origin/dev

fatal: refusing to merge unrelated histories

执行 pull 操作时,如果出现这个错误,是由于本地仓库和远程仓库有不同的开始点,也就是两个仓库没有共同的 commit 点而出现的无法提交。这里我们需要用到 --allow-unrelated-histories,也就是我们的 pull 命令改为下面这样的:

git pull --allow-unrelated-histories

fix conflicts and then commit the result

pull 操作会自动进行合并,但产生了冲突。一般会有提示是哪个文件产生冲突,找到对应的文件进行修改,再提交一次就行了


Git 本地推送远程失败 non-fast-forward

原文:https://www.cnblogs.com/Yee-Q/p/13769902.html

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