Live streamJoin us for "State of code review 2024" on July 18thRegister today

How to change a commit description in Git

Kenny DuMez
Kenny DuMez
Graphite software engineer


This guide explains this concept in vanilla Git. For Graphite documentation, see our CLI docs.

This guide covers the steps and best practices for changing commit descriptions in Git to maintain clear and accurate project histories.

A commit description is a brief explanation attached to each commit that describes the changes introduced.

Changing a commit message should be done with caution, especially for commits that have already been shared with others or pushed to a public repository. It's appropriate to modify a commit description if:

  • The message contains incorrect, incomplete, or misleading information.
  • The commit has not yet been pushed to a public branch or shared with other collaborators.

If you need to change the description of the most recent commit that has not been pushed yet, you can use the git commit --amend command:

  1. Open your terminal and navigate to your repository directory.

  2. Run the following command to modify the last commit:

    git commit --amend

    This command will open your configured text editor (such as Vim, Nano, or Notepad++) with the most recent commit message loaded for editing.

  3. Edit the commit message, save the file, and close the editor. The commit description will be updated for your last commit.

To change the description of an older commit, you must perform an interactive rebase. Be aware that this method rewrites commit history, which can cause issues for other collaborators if not handled carefully.

  1. Identify the commit hash of the commit you want to change by viewing the history:

    git log
  2. Start an interactive rebase to the parent commit of the commit you need to change:

    git rebase -i <commit_hash>^

    Replace <commit_hash> with the hash of the commit you want to change.

  3. Change pick to reword for the commit you wish to change the description of.

  4. Save and close the editor. Git will start the rebase process and stop to allow you to change the commit message of the commit you specified.

  5. Edit the message, save the file, and close the editor.

  6. Complete the rebase by following any on-screen instructions to resolve conflicts or continue the rebase.

After amending your commit locally, you need to push the changes to Git. If the commit has already been pushed, you will need to force push. However, be cautious as this can disrupt the history for others who have cloned the repository.

git push --force

For further reading see the official Git documentation.

Stay unblocked. Ship faster.
Experience the new developer workflow - create, review, and merge code continuously. Get started with one command.
Get started

Give your PR workflow
an upgrade today

Stack easier | Ship smaller | Review quicker

Or install our CLI.
Product Screenshot 1
Product Screenshot 2