Push rejected: Push to origin/master was rejected

Posted wangxiaoyu-

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Push rejected: Push to origin/master was rejected相关的知识,希望对你有一定的参考价值。

在用intelliJ idea新建java项目时,想把代码push到git上,出现错误:

            Push rejected: Push to origin/master was rejected

    百度得知,这种情况一般是在第一次提交代码库的时候会出现,原因是:你的本地仓库和git上的初始化仓库是没什么关联的,所以在第一次提交时会出现这个错误。

    解决方法:

           进入你的项目目录,右键项目,选择“Git Bash here”;

   前提: git remote -v  #找到origin链接

           输入命令:git pull {origin} master --allow-unrelated-histories

                           git pull {origin} master

           然后,在idea中继续push and commit,就可以了。



以上是关于Push rejected: Push to origin/master was rejected的主要内容,如果未能解决你的问题,请参考以下文章

Push rejected: Push master to origin/master was rejected /failed to push some refs to /git did not

Push rejected: Push to origin/master was rejected

git问题--Push rejected: Push to origin/master was rejected

IDEA工具上传项目报:Push rejected: Push to origin/master was rejected

解决上传代码到GitHub报错Push rejected: Push to origin/master was rejected

Git上传项目提示Push rejected: Push to origin/master was rejected解决办法