git push报错: hint:Updates were rejected because the tip of your current branch is behind

当你和同事共同开发一个git项目

提交自己代码前,先更新

git pull

提示

From: ......
error:your local changes to the following files would overwritten by merge: 你修改文件的路径
Please commit your changes or stash them before you merge
Aborting

此时有人比你先提交了代码

git add .
git commit -m "这是一次提交的备注信息"

继续提交后,报错

git push
To ......
![rejected] .....
error:failed to push some refs to '.....'
hint:Updates were rejected because the tip of your current branch is behind
hint:its remote counterpart...
hint:'git pull ...'before pushing again
hint:See ...

根据提示,我们更新

git pull

此时会弹出一个窗口
借用别人的图片
这里的操作步骤:

  1. 按 i 进入插入模式
  2. 修改黄色字体那一行,写上你的提交备注“这也是一次提交的备注信息“
  3. 按Ese
  4. 输入 :wq
  5. 回车

即可正常更新别人提交的代码到本地。

git status .
on branch dev
your branch is ahead of 'orign/dev' by 2 commits
(use 'git push' to publish your local commits)

此时再次push即可

git push

进入你的git项目查看提交信息的 History会看见两条记录:

  • “这是一次提交的备注信息” 的pipeline 没通过
  • “这是也一次提交的备注信息” 的pipeline 通过了

问题解决。

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值