For example, there are 2 feature branches, dev_logic and dev_styles. We are in master. We want to merge these 2 branches so that they have linear history, as if one feature is developed following the other feature.
We want to checkout one of the branch. In this example, we checkout
Then we call
git rebase -i dev_logic. After going through the interactive mode, we end up have
dev_styles applying after
I like to use interaction mode because I can go through the rebase step-by-step. In between, I can also squash multiple commits into 1 commit.
Please note that rebase is not moving commits to the target branch. It is re-creating commits on the target branch. The SHA hash is different after rebase. So don’t rebase branches that have already push to remote because others may have already working on it.