Cheatsheet Pages / Git Cheatsheet

How to rebase your branch onto the latest main in Git

Your feature branch fell behind main and you want your commits replayed on top of the latest code.

git fetch origin             # get the latest main first
git rebase origin/main       # replay your commits on top of it

Good to know

The golden rule of rebase: never rebase commits that others have already pulled. Rewriting shared history breaks your teammates' repos — rebase your own private branches freely; use revert or merge for shared ones.

Git Cheatsheet one-page card — 30 daily and rescue commands
The full one-page card — Git Cheatsheet. Get the complete cheatsheet on GitHub