Junior — Middle
What will happen to the commit sequence if you perform a rebase operation instead of a merge?
sobes.tech AI
Answer from AI
The rebase operation changes the commit history by transferring your local commits on top of the target branch, creating new commits with new hashes. As a result, the commit sequence becomes linear, without additional merge commits.
Unlike merge, which combines branches while preserving both histories, rebase rewrites history, making it cleaner and more understandable.
For example, if you have a feature branch based on master, and master has been updated, then:
git merge masterwill create a new merge commit, preserving both histories.git rebase masterwill transfer your commits on top of the latest commit of master, changing their hashes.
It is important to remember that rebase is not recommended for public branches, as it alters history and can cause conflicts for other developers.