O.D.
O.D.

Reputation: 261

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

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

Upvotes: 25

Views: 15622

Answers (2)

sergej
sergej

Reputation: 17999

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.

Upvotes: 47

Tim Biegeleisen
Tim Biegeleisen

Reputation: 521103

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.

Upvotes: 4

Related Questions