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


相关文章:

  • 2022-12-23
  • 2021-11-10
  • 2022-02-07
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2022-02-18
  • 2022-12-23
  • 2022-12-23
  • 2021-08-06
  • 2022-12-23
  • 2021-09-18
相关资源
相似解决方案