问题描述:
在github上远程仓库main分支上创建了一些代码,想把本地仓库的main分支上的内容推入远程仓库,将二者合并,但是出现了错误:
! [rejected] main -> main (non-fast-forward)
error: failed to push some refs to 'github.com:sherlyxoxo/frontend-notebook.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.
Integrate the remote changes (e.g. 'git pull ...') before pushing again.
这里提示了要用git pull命令,将远程仓库里的最新代码拉到本地来,再将本地的推过去
(也有人推荐为了更安全,使用git fetch + git merge 代替git pull的,这两种办法都行的,有的人到这里问题就解决了)
但是我执行了git pull命令后,又报错:fatal: refusing to merge unrelated histories,无法将远程仓库的代码拉到本地来。
原因分析:
可能是这两个仓库