问题描述
昨天第一次上传代码是这样的:原来在两个代码仓库的前后端文件,被我拉到了同一个文件夹,本来想上传到gitlab,途中出现报错了,应该是因为.git文件没有删除。
然后我又上传了一次,报错了。更新被拒绝,因为当前分支的提示已过期,其实应该是因为上面有两个空文件夹和.ignore文件。
解决方案
1.首先把代码仓库克隆下拉,并且查看代码仓库文件有哪些。
git clone https://gitlab.com/meshow/mssAdmin.git
cd mssAdmin
dir
2.这个时候会出现目录中有的文件,我们一个一个删除了。 删除mss_server文件夹
git rm -r --cached mss_server
删除README.md文件
git rm
3.把更新过的提交的远程仓库。
git add .
git commit -m "Initial commit"
git push -u origin master
4.又出现新的错误
Updates were rejected because the remote contains work that you do
hint: not have locally. This is usually caused by another repository pushing
hint: to the same ref. You may want to first integrate the remote changes
hint: (e.g., 'git pull ...') before pushing again.
5.先把远程代码pull下来
git pull --rebase origin master
6.再次上传,终于传好了
git add .
git commit -m "Initial commit"
git push -u origin master