当你和同事共同开发一个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
此时会弹出一个窗口
这里的操作步骤:
- 按 i 进入插入模式
- 修改黄色字体那一行,写上你的提交备注“这也是一次提交的备注信息“
- 按Ese
- 输入 :wq
- 回车
即可正常更新别人提交的代码到本地。
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 通过了
问题解决。