Rewriting Git History with Rebase in Magit

Charl Botha has a useful video on rewriting Git history with Magit. Botha gives three examples:

  1. Changing the commit message on any old commit
  2. Squashing two or more commits into one
  3. Splitting a commit into two or more separate commits

These are all accomplished by rebasing. In all of these, you bring up the rebase menu from the Magit status buffer by pressing 【r】.

For example, to rewrite an old commit message you bring up the log with 【l l】 and move the cursor to the commit you wish to reword. The you call up the rebase menu and choose 【w】 to rewrite the commit message.

The other cases are a bit more complex but follow the same general procedure. Take a look at Botha’s post for the details. The video is a few seconds over 15 minutes so you can probably fit it into a coffee break. It’s a useful adjunct to Howard Abrams’ Magit Introduction and Demonstration video, which covers some of the same material.

This entry was posted in General and tagged , . Bookmark the permalink.