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

亡梦爱人 提交于 2020-03-03 05:12:05

当你和同事共同开发一个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 通过了

问题解决。

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!