Categories
Workflow

Squashing Git Commits

Assuming none pushed to origin.

git rebase -i HEAD~n where n is number of recent commits to squash.

Vim will show commits from oldest to newest.

  • i to enter interactive mode.
  • make changes. Esc to leave interactive mode
  • :w to write
  • : x to execute (remove space between : x. Preventing emoji render)

PICK the oldest (first line).  SQUASH the subsequent commits.

Do a similar thing with Vim to edit the new commit message (interact, save, execute)

Leave a Reply

Your email address will not be published. Required fields are marked *