Skip to content

Latest commit

 

History

History
29 lines (17 loc) · 1.1 KB

git-rebase.md

File metadata and controls

29 lines (17 loc) · 1.1 KB

Git Rebase

Unlike merge, that squashes all the commits into one merge commit, rebase preserves the original commits. After the rebase, commits structure is in the single line.

This is the example of the situation before the rebase:

starting-situation-before-rebase

If we want to integrate changes from branch-B into branch-A, we will use the following command:

git rebase branch-B

First, Git will temporary remove all changes on branch-A that happened after common ancestor commit(C1):

rebase-step-1

Next, all the commits from branch-B are applied:

rebase-step-2

In the final step, commits from branch-A that were temporary removed are now replayed. But they will be in new position, on top of the integrated commits from branch-B. This is the resulting structure:

rebase-step-3

Resources: