赞
踩
按照习惯,先放结论:
执行 git rebase --continue 到 Successfully rebased and updated refs/heads/dev 后,下一步需要 push 到自己的分支上,执行:
git push origin dev --force 即可。
注意,千万不要在 master 分支上改,要在自己 git branch 出来的分支上修改。
----------------------- 分割线-------------------------
下面聊聊此次踩坑的一点心得。
最近被要求使用 git rebase,控制一下个人提交 mr 时 commit 的个数。
期间我花了一下午的时间尝试研究这个问题,结果每次到 Successfully rebased and updated refs/heads/dev 后,使用 git push origin dev ,会提示:
! [rejected] dev -> dev (non-fast-forward)
error: failed to push some refs to gitXXXX
hint: Updates were rejected because the tip of your current branch is behind
hint: its remote counterpart. Integrate the remote changes (e.g.
hint: 'git pull ...') before pushing again.
hint: See the 'Note about fast-forwards' in 'git push --help' for details.
然后我就根据提示 git pull origin dev ,再 git push origin dev。最后发现,git log 不对啊,还是好几个 commit,我 rebase 了个寂寞啊,所以,当执行到 Successfully 这一步的时候,千万不要 git pull,否则就前功尽弃了。
最后经过我的不懈努力 + 向大佬求救,终于成功了。有需要的话,改天手把手的带大家走一遍 git rebase 的流程。
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。