2

I just realized that I left one word in the commit message of a previous commit (so I can't use git commit --amend) that makes the message mean completely the opposite of what I had intended.

The commit in question is HEAD~2 on my current branch, which is ahead of the branch base. How can I edit just the message on that commit?

David Sanders
  • 4,069
  • 1
  • 24
  • 38
  • Possible duplicate of [How to modify a specified commit in git?](http://stackoverflow.com/questions/1186535/how-to-modify-a-specified-commit-in-git) – approxiblue Mar 23 '16 at 00:13
  • Sure, the answer in the other question does apply but my question is more simple and the chosen answer is, likewise, simple and concise. That has value. – David Sanders Mar 23 '16 at 00:46
  • It does. I'm just marking this question as duplicate, I'm not saying we need to remove it or anything. – approxiblue Mar 23 '16 at 03:10

1 Answers1

3

Use interactive rebase and mark that commit with r (reword):

git rebase -i HEAD~3

Don't use rebase if your history was already made public

knittl
  • 246,190
  • 53
  • 318
  • 364
  • 1
    Okay, I didn't push this branch. So I'm supposed to use that command on the parent of the commit I want to change? – David Sanders Oct 03 '11 at 15:16
  • 1
    You just want to have your commit in that list, so either the parent or the branch base will work in this case... in most cases you want to rebase from the branch base to reword/reorder/squash commits in the entire set of commits you are about to push. – UncleZeiv Oct 03 '11 at 15:20