Maintain Your Feature Branches
Keep Feature Branches Up-to-Date Using git merge or git rebase.
1. Scenario: Branch originated from master
In this scenario, the feature can be kept up-to-date either by merge or rebase.
Since the branch originated from master, both methods will bring the changes to the feature branch.
And in the PR view of this branch, we would see only related commits that are going to be merged to the master branch.
2. Scenario: Branch originated from another branch than master
Suppose we have two branches:
feat/feature-1: A branch that introduces major changes and is actively developed.feat/feature-2: A branch based onfeat/feature-1.
If feat/feature-1 is merged to master using a squash merge, feat/feature-2 will no longer have a straightforward history compared to master. This can create significant rebase complications.
Caveats:
- Rewriting History: Rebasing rewrites commit history, which may require force-pushing (
git push -f). Be careful not to overwrite others' work, and always communicate with your team if you are sharing branches.