Quick Scoop

git rebase moves your commits onto a new base commit, so your branch looks like it started from the latest version of another branch. It usually gives you a cleaner, linear history than a merge, but it rewrites commit history by creating new commits.

What it does

  • Takes the commits on your branch.
  • Replays them on top of another branch’s latest commit.
  • Makes the history easier to read because it avoids an extra merge commit in many cases.

Simple example

If your feature branch started from an older main, rebasing it onto current main makes Git apply your feature commits again on top of the newest main changes. That can help when you want to update your branch before merging.

Important caution

Because rebase rewrites history, it’s best to avoid rebasing commits that other people are already using unless your team specifically wants that workflow. Interactive rebase can also be used to squash, reorder, or edit commits.

If you want, I can also show the difference between rebase vs merge in one small example.