Git Update Commit Message

By  on  

One of my faults as a professional developer is that my commit messages aren't always as descriptive as they could be.  Sometimes I even notice a spelling error in them.  Bleh -- that's not cool, man.  When I do catch that my last commit message isn't good enough, I find the following git command useful:

The command below rewrites the message for the previous commit.  You can omit the -m and message to go into the commit shell instead.

git commit --amend -m "This is the new message"

Do realize, however, that performing this after you've pushed to a remote repo is considered bad as it rewrites history. If you haven't pushed, however, the command above is gold!

Recent Features

  • By
    Create a CSS Flipping Animation

    CSS animations are a lot of fun; the beauty of them is that through many simple properties, you can create anything from an elegant fade in to a WTF-Pixar-would-be-proud effect. One CSS effect somewhere in between is the CSS flip effect, whereby there's...

  • By
    From Webcam to Animated GIF: the Secret Behind chat.meatspac.es!

    My team mate Edna Piranha is not only an awesome hacker; she's also a fantastic philosopher! Communication and online interactions is a subject that has kept her mind busy for a long time, and it has also resulted in a bunch of interesting experimental projects...

Incredible Demos

  • By
    background-size Matters

    It's something that makes all men live in fear, and are often uncertain of. It's never spoken, but the curiosity is always there. Nine out of ten women agree in the affirmative. Advertisers do their best to make us feel inadequate but...

  • By
    DWRequest: MooTools 1.2 AJAX Listener & Message Display

    Though MooTools 1.2 is in its second beta stage, its basic syntax and theory changes have been hashed out. The JavaScript library continues to improve and become more flexible. Fellow DZone Zone Leader Boyan Kostadinov wrote a very useful article detailing how you can add a...

Discussion

  1. This is one of the things I do more frequently :-/

    The good thing is that, with amend, you can also include in the commit new changes (provided that you have added them to the staging area).

    The drawback is that it’s **bad** to amend a commit that has already been pushed to a remote repository.

  2. May I point you to an article of my own, in which I describe some more solutions on how to change commit messages:

    http://www.gamez.name/change-commit-message-git/

  3. Dorian Marchal

    Be careful, this command rewrites history and shouldn’t be used if you already pushed your last commit.

  4. And you are noticing it now? :D

    One thing to remember is HASH is changed on amending.

  5. And you are noticing it now? :D

    Well, one thing to notice is that HASH of that particular commit is rewritten when amending.

Wrap your code in <pre class="{language}"></pre> tags, link to a GitHub gist, JSFiddle fiddle, or CodePen pen to embed!