Push rejected: Push to origin/master was rejected

    在用intelliJ idea寫Java生成和解析二維碼代碼,想把代碼push到github上,出現錯誤:

            Push rejected: Push to origin/master was rejected

    百度得知,這種情況一般是在第一次提交代碼庫的時候會出現,原因是:你的本地倉庫和github上的初始化倉庫是沒什麼關聯的,所以在第一次提交時會出現這個錯誤。

    解決方法:

           進入你的項目目錄,右鍵項目,選擇“Git Bash here”;

           輸入命令:git pull origin master --allow-unrelated-histories

                           git pull origin master

           然後,在idea中繼續push and commit,就可以了。

     

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章