Sentry Answers>Git>

Modify an existing unpushed commit message in Git

Modify an existing unpushed commit message in Git

David Y.

The ProblemJump To Solution

In Git, how do I modify the commit message for a commit I’ve made but not yet pushed to a remote?

The Solution

We can use git commit --amend to edit the latest commit message. Running this command will open an editor containing the existing commit message. We can then change the message, save the file, and close the editor. Behind the scenes, Git will replace our existing commit with a new one containing all the same changes as well as the modified message.

If we don’t want to change the existing message in an editor, we can specify the -m flag with a new message:

Click to Copy
git commit --amend -m "Corrected commit message."
  • ResourcesWhat is Distributed Tracing
  • Syntax.fm logo
    Listen to the Syntax Podcast

    Tasty treats for web developers brought to you by Sentry. Get tips and tricks from Wes Bos and Scott Tolinski.

    SEE EPISODES

Loved by over 4 million developers and more than 90,000 organizations worldwide, Sentry provides code-level observability to many of the world’s best-known companies like Disney, Peloton, Cloudflare, Eventbrite, Slack, Supercell, and Rockstar Games. Each month we process billions of exceptions from the most popular products on the internet.

© 2024 • Sentry is a registered Trademark
of Functional Software, Inc.