Git & GitHub Interview Question #46

What is interactive rebase?

Remotes, Fetch, Pull, Push, Merge, Conflicts, Rebase & Stash Mid-Level Intermediate

Quick Interview Answer

Interactive rebase allows selected commits to be reordered, combined, edited, reworded, or removed while rewriting a portion of history. It is commonly used to clean up local feature-branch commits before they are shared.

Detailed Explanation

Interactive rebase allows selected commits to be reordered, combined, edited, reworded, or removed while rewriting a portion of history. It is commonly used to clean up local feature-branch commits before they are shared.

Because interactive rebase changes commit identities, avoid rewriting history that other developers already depend on unless the team has explicitly coordinated it.

Code Example

# Edit the last 4 commits
git rebase -i HEAD~4

# Common actions in the editor:
# pick, reword, edit, squash, fixup, drop