Updates were rejected because the tip of your current branch is behind的解决方案

问题描述

昨天第一次上传代码是这样的:原来在两个代码仓库的前后端文件,被我拉到了同一个文件夹,本来想上传到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 

在这里插入图片描述

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

洛阳八中我最棒

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值