有人在你pull代码之后push过,然后我再push就出这种下面这种报错:
git push之后报错:
To code.ghhg.org:gg/aaa.git
! [rejected] feature/publish -> feature/publish (fetch first)
error: failed to push some refs to 'git@code.ghhg.org:gg/aaa.git'
hint: 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.
hint: See the 'Note about fast-forwards' in 'git push --help' for details.
解决方法:
git rebase origin/远程分支名
git push
rebase的作用就是在你本地再回放一下目标分支领先的commit,然后继续执行相关命令即可。