DEV Community

Discussion on: Beginner's Guide to Interactive Rebasing

Collapse
 
jrock2004 profile image
John Costanzo

The one thing that I still have not grasped in Git, is to when to rebase. I know this article is about interactive rebasing, but when would you typically rebase? Would it be to just remove a bad commit from the tree? Thanks

Collapse
 
sutina_w profile image
Sutina W

There are a couple of scenarios where I would do rebasing:

  1. When my new change is related to an older commit, could just simply be adding a comment to a function. I prefer a rebase over a new commit as it would keep my history clean and easy to understand when looking back in the future.

  2. When pulling change from other branches, such as develop. Usually, depending on the team I'm working with. Some teams do like a clean history thus rebasing is their preference when it comes to pulling change from the main branch.

  3. Removing bad commits is, of course, one of the usages! There are countless times where I hack something together and commit it as a "working progress" so that I won’t lose it. Rebasing is my lifesaver to clean up my commits later.

Hope this helps 😊