#TIL 1 - Git Rebase Interactive

Aug 11, 2020 · Dung Huynh

What

Interactive rebase to squash, reorder, or edit recent commits.

Why

Clean commit history before submitting PRs. Combine related commits or fix mistakes.

How

git rebase -i HEAD~N

Replace N with the number of commits to edit. In the editor:

  • squash / s: combine with previous commit
  • drop / d: remove commit
  • reword / r: edit commit message
  • pick / p: keep commit as-is