rebase

What is git rebasing?

rebasing is changing the base of your branch from one commit to another making it appear as if you'd created your branch from a different commit. Internally, Git accomplishes this by creating new commits and applying them to the specified base

For example:

  1. You create the branch Feature-1 from the master branch.

  2. Now the master branch gets updated and differs from the base the branch Feature-1 was based upon.

  3. In order to rebase your branch (so you get the updated code that is currently on the master branch processed into your branch) you type the following command ON the Feature-1 branch

  4. git rebase master

  5. Now you should have your branch updated with the latest version of the master branch

Unwritten rule

  • Merge to the master branch and rebase the feature branches

Rebasing will also keep the log intact on your feature branch. Checkout this video between 9:20 and 10:20 to understand the concept better.

How to use git rebasing?

follow the steps in the video, which can be found in the references

References

Last updated