Mid Version Control

How do you rewrite commit history? (e.g., git rebase -i)

You can interactively rebase to edit, squash, or reorder commits using:

git rebase -i HEAD~3

This opens an editor showing the last 3 commits:

pick 1a2b3c Fix typo in footer

pick 4d5e6f Add login API

pick 7g8h9i Update UI color scheme

You can change:

Follow:

  • pick → edit to modify a commit
  • pick → squash to combine commits
  • pick → reword to change the message

Real-world example:

Before merging your feature branch, you may use git rebase -i to combine small “fix

typo” or “debug print” commits into a clean, single commit.

⚠ Don’t rewrite history on shared branches that others are using — it can

cause conflicts and confusion.

GitHub & Remote Repository

Management

More from Developer Essentials

All questions for this course