美文网首页
git push 码云项目时报错! [rejected]

git push 码云项目时报错! [rejected]

作者: 吃肉肉不吃肉肉 | 来源:发表于2020-12-03 22:30 被阅读0次

    git切换远程分支后,想要push到另一个远程仓库,执行 git push origin master后此时报错:

    To gitee.com:***
     ! [rejected]        master -> master (non-fast-forward)
    error: failed to push some refs to 'gitee.com:***'
    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.
    

    在网上搜了好久,输入了各种无效和错误的命令后,终于找到了解决办法:
    1、git pull origin master --allow-unrelated-histories //把远程仓库和本地同步,消除差异

    2、重新add和commit相应文件

    3、git push origin master

    4、此时就能够上传成功了

    相关文章

      网友评论

          本文标题:git push 码云项目时报错! [rejected]

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