Sobes.tech
Junior — Middle

What changes occur in the commit history when using the rebase command sequentially to merge two branches with their common base?

sobes.tech AI

Answer from AI

When using the git rebase command sequentially to merge two branches with a common base branch, it rewrites the commit history of one branch on top of the other. As a result:

  • Commits from one branch are 'moved' to the top of the other, creating a linear history.
  • Commit identifiers (hashes) are changed because their parent commits change.
  • The history becomes cleaner and easier to understand, without unnecessary merge commits.

For example, if there are branches feature and develop, both originating from the main base branch, then rebasing feature onto develop will rewrite the feature commits as if they were based on the latest commit of develop.

This is useful for maintaining a tidy history but requires caution when working collaboratively to avoid losing changes.

What changes occur in the commit history when using… - sobes.tech