Rebasing

In the post “Merging” we already explained one method how to apply changes from one branch to another. “Rebasing” is similar but the applied changes come from a “different” direction than from merging.

“Rebasing” allows you to move the point of where you started your branch.

Lets say we have this state in the repository:

So on the master branch we have done 2 commits, then created a Feature branch from that point in the repository but also added 2 more commits to the master branch after creating the feature branch.

The current commit when creating a branch is called the “base” for this new branch.

But if you add more commits to the master branch after you created the feature branch these changes will not be visible to the feature branch. But what if you want to have these changes in your feature branch but don’t want to merge the feature branch into the master?

With that you now can do a “rebase” on the currently active feature branch:

git rebase master

With this command we basically perform this “transformation” in the repository:

Share this post

Leave a Reply

Your email address will not be published. Required fields are marked *

This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

The reCAPTCHA verification period has expired. Please reload the page.