首次提交本次代码到gitlab上,报错:Updates were rejected because the remote contains work that you do

报错情况如下:

【gitlab】首次提交本次代码到gitlab上,报错:Updates were rejected because the remote contains work that you do-LMLPHP

错误原因:

由于在gitlab上新建空项目时候,勾选了Initialize this repository with a README这项,导致远程仓库不为空

【gitlab】首次提交本次代码到gitlab上,报错:Updates were rejected because the remote contains work that you do-LMLPHP

也就是 此刻的空项目是

【gitlab】首次提交本次代码到gitlab上,报错:Updates were rejected because the remote contains work that you do-LMLPHP

解决方法:

现将远程仓库的内容拉取到本地,然后再进行提交

1.删除gitlab上现有的空项目,新建项目,不要勾选Initialize this repository with a README这项

【gitlab】首次提交本次代码到gitlab上,报错:Updates were rejected because the remote contains work that you do-LMLPHP

2.再重新push代码到gitlab上

【gitlab】首次提交本次代码到gitlab上,报错:Updates were rejected because the remote contains work that you do-LMLPHP

即可成功

05-02 06:28