- 更新到最新的base分支
$ git checkout <base-branch>
$ git pull <base-branch>
- 更新到最新的工作分支
$ git checkout <work-branch>
$ git pull <work-branch>
- 执行rebase操作
期间可能需要解决冲突,或者放弃rebase操作。
$ git rebase <base-branch>
# resolve conflict
$ git add/rm <file>
$ git rebase --continue/--abort
- 提交回远程代码库
$ git push --force-with-lease
- --force-with-lease
因为所有本地的commits的hash值都被重写了,所以必须使用--force参数。
使用"--force-with-lease"来代替"--force"可以更安全的提交代码。源文解释是:it ensures you're not accidentally overwriting other people's changes. It checks if someone else has pushed changes to the branch you're trying to push to.
不过如果只有你一个人在这个分支上工作,用--force也是可以的。









网友评论