Change the commit message with git

Posted in Linux/Unix/BSD -

I'm sure you've done it before: added a commit message with git but typed it in wrong and need to change it. If you haven't pushed the commit yet then it's as simple as 'git commit --amend -m "New commit message"'.

Quick answer

If you haven't yet pushed the commit, use this to edit it in a text editor:

git commit --amend

Use this to do the whole thing from the command line:

git commit --amend -m "New commit message"

The full answer / more answers

I need a quick reference link to a comprehensive answer myself, hence this quick post. Several useful answers and examples covering a variety of situations is here at Stack Overflow.



Related posts:


Comments