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

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

报错情况如下:

错误原因:

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

也就是 此刻的空项目是

解决方法:

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

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

2.再重新push代码到gitlab上

 即可成功

原文地址:https://www.cnblogs.com/sxdcgaq8080/p/10528991.html