在idea第一次将本地仓库的代码上传到远程仓库是总是出现push was rejected,下面比较通用的解决方案。 1.在terminl窗口中依次输入命令: git pull git pull origin master git pull origin master --allow-unrelated-histories 2.再次向gitee/gitlab push成功!!!