How to rebase my feature branch to development branch in git with least possible conflicts?

无人久伴 提交于 2019-12-05 00:57:39

The workflow is sound (rebase).
But the conflicts should not be resolved every time over and over again.

For that, you have git rerere: activate it (git config --global rerere.enabled true), resolve the conflict one last time (or do a manual re-training, or use contrib/rerere-train.sh), and your next rebase will resuse those conflict resolution at your next rebase.

I would suggest to keep your feature small (one or two days), and your feature branch will be small as well. Another way would be to rebase not every time something got pushed to development branch but only sometimes, or just once before the merge. Again you need to keep the feature small or you will have too many conflics all at once.

About your question, you cannot minimize the number of conflics in a rebase. If there are conflics you cannot avoid them.

But there is one way git can help you: I suggest you to enable rerere which stands for reuse recorded resolution. With this, git records how you resolve a conflict and the next time the conflict appears, the resolution is reapplied so that you find the conflict already resolved. This sould speed up your workflow.

You can enable rerere globally with

git config --global rerere.enabled true

Try to git merge from the development branch into the feature branch before you perform the git rebase. It will be more informative in the way.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!