git rebase — What It Does & How to Use It

git rebase reapplies your branch's commits onto a different base, creating a linear history. Use -i for interactive editing (squash/reword/drop) and --onto to specify a new base. Don't rebase shared history after push.

Open the interactive DevRef Hub tool →

Key facts

Basicgit rebase main
Interactivegit rebase -i HEAD~5
New basegit rebase --onto main feature-base feature/x
Resume--continue / --abort

Frequently asked questions

What does git rebase do?

It replays your commits onto another base to create linear history.

git rebase vs merge?

Rebase rewrites commits for a linear history; merge keeps both histories with a merge commit.

Related pages

git rebase is part of DevRef Hub on GOAT Lab — a free reference you can use without signing up, and it works offline. Open the tool above for any custom value.

Advertise

Part of GOAT Lab — 26 free, browser-based science, engineering and developer tools. No sign-up.