美文网首页
git push origin master提交报错解决办法

git push origin master提交报错解决办法

作者: 祈澈菇凉 | 来源:发表于2021-04-03 15:59 被阅读0次

    使用git push origin master将本地提交推送到远程仓库的时候
    遇到了这样的一个报错

    wangting@DESKTOP-O81VEVO MINGW64 ~/Desktop/wisdom_inventory_admin (master)
    $ git push origin master
    To https://gitee.com/wangyoko/wisdom_inventory_admin.git
     ! [rejected]        master -> master (fetch first)
    error: failed to push some refs to 'https://gitee.com/wangyoko/wisdom_inventory_admin.git'
    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.
    hint: See the 'Note about fast-forwards' in 'git push --help' for details.
    

    原因是远程仓库中的文件和我们本地的仓库有差异,例如你的远程仓库有个文件Readme. md,但是本地仓库却没有,就可能会出现这种情况。

    本地仓库:


    远程仓库:


    解决办法

    git pull origin master --allow-unrelated-histories
    

    将远程仓库的Readme. md一起拉下来同步到本地

    再次执行
    git push origin master


    ok,远程仓库同步代码


    相关文章

      网友评论

          本文标题:git push origin master提交报错解决办法

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