U r s u s
U r s u s

Reputation: 6968

``git pull - -rebase` on feature branches

I'm trying to modify slightly my workflow and I need help in understanding two different scenarios.

Scenario 1

Using ​git pull - -rebase​ on feature branches to keep them up to date. Normally I would manually rebase but the rebase flag seems like a bit less ceremony.

Scenario 2 Rebasing manually off master and using ​git pull —rebase​ on master.

What's the difference between the two scenarios?

A branch visualisation would be helpful thanks.

Upvotes: 0

Views: 109

Answers (1)

Tim Biegeleisen
Tim Biegeleisen

Reputation: 520898

Based on your latest comment, you are looking for an explanation to the difference between:

Rebase your feature branch directly off the upstream branch (scenario 1) vs rebase off a local master (scenario 2)

In scenario 1, all users working on the feature branch will bring in new remote changes to the feature by rebasing on feature. This presumably means that they would then be fast-forwarding the remote feature branch with their changes. Assuming everyone obeys this workflow, the end result would be a completely linear feature branch. When it comes time to bring the feature back into master, you could either merge it or rebase it; the choice would be up to your preference. However, given the overhead in maintaining a linear feature branch, this option would make the most sense if you wanted to rebase in the entire feature into master. This would leave your entire commit history intact in the final master branch, which would make history easier to read.

For scenario 2, it first must be noted that rebasing off a local master isn't really different than rebasing on the remote master, since the local copy of master should always be kept up to date. Therefore, you are describing rebasing the feature on the remote master. In this scenario, users working on the feature would rebase on master, which potentially has a different base than feature. This means that after a rebase, a user may have to force push their branch out to the remote. This could potentially cause problems for anyone else who is also using this branch. For this reason, I don't recommend scenario 2 for situations where multiple users may be concurrently working on the same feature branch.

Upvotes: 1

Related Questions