本系列汇总,请查看这里:https://www.cnblogs.com/uncleyong/p/10854115.html
演示场景
虽然每次合并代码前会先把分支更新到最新,但是在你pull后到push前这段时间,可能其它小伙伴又push了,那么你的分支就不是最新的了
在push的时候就会失败,比如遇到这种提示信息:
- To gitee.com:qzcsbj/pytest_apiautotest.git
- ! [rejected] master -> master (fetch first)
- error: failed to push some refs to 'gitee.com:qzcsbj/pytest_apiautotest.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.
本篇我们演示这种场景,并用rebase解决冲突。
git pull --rebase = git fetch + git rebase