Practical Git via GitExtensions
  • Git - a Distributed System
  • Bare Minimal Configurations
  • Creating a New Branch
  • Making a Commit
    • Adding only a portion of a file
    • Commit Message
    • Cherry-pick
    • Revert
  • Rewriting History
    • Rewording the Last Commit
    • Rewording Commit Message in Middle
    • Editing the Last Commit
    • Squashing Last Few Commits
    • Squashing Commits in Middle
    • Spliting Commit into Multiple
    • Removing a Commit
    • Pushing after Rewriting History
  • Lost and Found
  • Comparing Commits or Branches
  • Checking out a Branch into Another Folder
  • Blaming History
    • Blame
    • Bisect
  • Disabling Auto Tracking Branch
  • Line Ending
  • Ignore Unwanted Files
Powered by GitBook
On this page

Was this helpful?

  1. Rewriting History

Rewording Commit Message in Middle

PreviousRewording the Last CommitNextEditing the Last Commit

Last updated 6 years ago

Was this helpful?

Interactive rebase needed to change the commit message for commits in middle like:

In this case, we right click the parent commit my awesome changes and select the interactive rebase menu.

Git then will popup the Editor with the content like below (the commits show in reverse order, the last is the most recent commit).

pick d310b7c35 WIP: Fix blah blah
pick f3ee84093 WIP: Continue Fix blah blah
pick 07ec28ec2 Fix another stupid bug

We now change the pick to r or reword (Unfortunately, we can't change the commit message here directly) and save and close the Editor.

r d310b7c35 WIP: Fix blah blah
r f3ee84093 WIP: Continue Fix blah blah
pick 07ec28ec2 Fix another stupid bug

Git will popup the Editor again asking for the new commit message for the first commit. Now put the new message and close the Editor and do the same thing for the second commit.

Commandline:

git rebase -i HEAD~3 
# or the parent commit SHA if it's hard to count
git rebase -i <TheParentCommitSHA>