Should I rebase with dev branch before making a pull request?

你。 提交于 2021-02-07 12:20:58

问题


Our current workflow:

create a feature branch from dev. after developing the feature and having pushed the branch do a the following:

git checkout dev

git pull --rebase (on dev)

git checkout my-feature-branch

git rebase dev

resolve conflicts and then do a git push -f or git push (first time).

My question comes from one of our development team members:

Do we need to do the whole process as is, or can we just make the pull-request directly, especially that the response is always "I am working on a component which is not shared by any other developer" ?

Thanks in advance


回答1:


Let's say, while you are working on your feature-branch, new stuff is integrated onto the dev branch. So the history might look like this:

1 - 2 - 3 - 5 (dev)
    \
     4 - 6 - 7 - 8 (feature-branch)

If you simply create a pull-request and the dev branch maintainer would have to merge it, he would need to deal with potential conflicts -- bad for the dev branch maintainer.

If you rebase the feature-branch branch onto dev and resolve potential conflicts before submitting the pull-request,

1 - 2 - 3 - 5 (dev)
             \
              4 - 6 - 7 - 8 (feature-branch)

it will be just a quick and easy fast-forward merge for the dev branch maintainer.

This workflow enforces developers to resolve conflicts locally and makes the live of the integrator easier.




回答2:


Your workflow is just the typical rebase workflow I would expect to see being used to keep a feature branch directly ahead of its ancestor, which in this case is the dev branch. If you want to leave open the possibility of the my-feature-branch fast-forwarding the dev branch during the pull request, then yes, you need to do all these steps. Note that the force push might be required because the rebase on dev can rewrite the history of the feature branch.

As to whether you should be doing a rebase workflow versus a merge or other workflow, this is subjective and depends on many things. But, if rebase does make the most sense, then I agree with your current steps and don't see a way to simplify it.



来源:https://stackoverflow.com/questions/51404094/should-i-rebase-with-dev-branch-before-making-a-pull-request

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