From the course: Use Git Like a Pro by Pearson

Unlock this course with a free trial

Join today to access over 25,300 courses taught by industry experts.

Rebase theory and concepts

Rebase theory and concepts

So far, we saw, in order to integrate our feature changes into master, we can check out to master branch and do git merge feature branch. We also saw that merging also creates additional merge commit to complete the merge. However, as an alternative to merging, you can use rebase to merge the feature branch into main using the following commands. In this case, you will first check out to your feature branch, then do git rebase master. Let's understand this better using an example. Let's say we are on master branch and master branch is pointing to commit C1. Now we want to work on our feature branch. So we will create a feature branch from C1. And we'll switch to this feature branch and create more commits. So now our feature branch is on C3, whereas our master branch is on C1. Now we made two more commits to the master branch. So now master branch is pointing to commit C5. If I want to merge my feature branch into master branch, one way is that I can go to the master branch and do git…

Contents