美文网首页
报错:fatal: refusing to merge unre

报错:fatal: refusing to merge unre

作者: 丶辣鸡丶 | 来源:发表于2018-12-17 22:45 被阅读0次

问题

github新建仓库后,添加了readme.md后怎么上传文件

报错

执行git push origin master

Push rejected: Push to origin/master was rejected

执行git pull

There is no tracking information for the current branch.
Please specify which branch you want to merge with.
See git-pull(1) for details.

    git pull <remote> <branch>

If you wish to set tracking information for this branch you can do so with:

    git branch --set-upstream-to=origin/<branch> master

执行git pull origin master

 * branch            master     -> FETCH_HEAD
fatal: refusing to merge unrelated histories

解决思路

因为在github上新建仓库的时候,就添加了readme.md文件,之后在本地仓库添加了文件,此时本地仓库和远程仓库的内容是不一样的,需要先把远程仓库的readme.md拉取到本地。

解决方案

执行 git pull origin master --allow-unrelated-histories
之后在push,即可

相关文章

网友评论

      本文标题:报错:fatal: refusing to merge unre

      本文链接:https://www.haomeiwen.com/subject/fmhckqtx.html