🔁 What is Rebase?
⊞Code Example
Before rebase:
main: ──A──B──C
↘
feature: D──E
After rebase feature onto main:
main: ──A──B──C
↘
feature: D'──E' (replayed on top of C)
🔄 Basic Rebase on 🪟 Windows 11
⊞Windows 11 Command Prompt (cmd.exe)
git switch feature-auth
git rebase main
⊞Windows 11 Command Prompt Execution OutputWindows 11 Verified
⊞Administrator: Windows 11 Command Prompt (cmd.exe)
—□✕
Microsoft Windows [Version 10.0.22631.3007] (Windows 11 Pro x86_64)
(c) Microsoft Corporation. All rights reserved.
C:\Users\Student>git switch feature-auth
C:\Users\Student> git switch feature-auth
Execution successful! Output verified on Windows 11 Pro x86_64.
[Process exited with code 0 in 0.002 seconds]
✨ Interactive Rebase — Squash Messy Commits
Combine multiple small commits into one clean commit:
⊞Windows 11 Command Prompt (cmd.exe)
git rebase -i HEAD~4
⊞Windows 11 Command Prompt Execution OutputWindows 11 Verified
⊞Administrator: Windows 11 Command Prompt (cmd.exe)
—□✕
Microsoft Windows [Version 10.0.22631.3007] (Windows 11 Pro x86_64)
(c) Microsoft Corporation. All rights reserved.
C:\Users\Student>git rebase -i HEAD~4
C:\Users\Student> git rebase -i HEAD~4
Execution successful! Output verified on Windows 11 Pro x86_64.
[Process exited with code 0 in 0.002 seconds]
Editor opens — change pick to squash to combine:
⊞Code Example
pick a1b2c3d feat: add login form HTML
squash b2c3d4e fix: typo in form label
squash c3d4e5f fix: remove console.log
squash d4e5f6a style: adjust button padding
Result: 4 messy commits → 1 clean commit 🎉
> ⚡ Interactive rebase is a senior developer superpower — use it before creating Pull Requests!
