RoBlog

Run Git prepare-commit-msg Hook on Previous Commits

I’ve had some people approach me after adding a git hook I made saying, now that I have the hook in place, how do I fix all my previous commits to use it?!

Once again, I offer some good news! It is possible and easy to run the git hook on your previous commits using Interactive Rebase.

Here is how you fix up all your previous commits to run the pre-commit hook you just added:

  1. Select commit prior to commits you want to run the hook on.
  2. Right-click > Rebase current branch on > Select Commit Hash
    Rebase Right-click
  3. Click Show options
  4. Check Interactive Rebase Interactive Rebase Check
  5. Press Rebase
  6. Your choosen Text Editor should open with git-rebase-todo window Rebase Todo
  7. Add exec git commit --amend -C HEAD after each commit Rebase Todo Edited
  8. Close the edit window
  9. Watch git do it’s work!

This project is maintained by RobertDeSonier