22

I a have a small problem with Git commit. So I am working on some project and using Git. I did a Git commit and I accidentally wrote a wrong commit message. So my question is:

Is there anyway I can change the commit message in Git?

NOTE: I have tried to do this way:

git commit -a --amend -m "New Commit Message"

But it doesn't work. Why?

Thanks.

Michael
  • 15,386
  • 36
  • 94
  • 143
  • Have you tried anything from [How do I edit an incorrect commit message in Git?](http://stackoverflow.com/questions/179123/how-do-i-edit-an-incorrect-commit-message-in-git). If your amend didn't work, did you get any error messages? Are you trying to change a commit message from a commit that comes before your most recent commit? –  Aug 13 '13 at 12:18
  • ok, sorry i didn't saw this question – Michael Aug 13 '13 at 12:20

1 Answers1

5

Lose the first -a you aren't adding any files, you're just changing the HEAD commit:

git commit --amend -m"New Commit Message"
Abizern
  • 146,289
  • 39
  • 203
  • 257
  • The `-a` isn't a problem, it will work with it, even if the original poster isn't committing anything new. –  Aug 13 '13 at 12:22