Workflow: Editing an old commit's message - arxanas/git-branchless GitHub Wiki

Description

Sometimes, you may want to edit the message of a commit. Perhaps you're making "temporary" commits and cleaning them up later, or you're responding to feedback from a code review.

If you want to change the contents of a commit (i.e the code itself), see Editing an old commit's contents.

Setting the default editor

To specify which editor is opened to update the commit message, follow the instructions at How do I make git use the editor of my choice for commits?

Approaches

Updating a single commit message

To update the content of a commit message, simply use the git reword command:

$ git reword my-branch

# or

$ git reword abc123

You can also pass -m/--message to specify the commit message inline:

$ git reword my-branch -m 'update some code'

Updating multiple commit messages

You can also update multiple commit messages at once. This can be useful if you are updating common information (such as a ticket number) or have a lot of temporary commits.

Pass multiple branches or commit IDs to git reword and it will open all of their commit messages in the same window:

$ git reword my-branch-1 my-branch-2 my-branch-3

You can also use revsets to specify commits in a more ergonomic way. For example, to specify all commits in the current commit stack, use the stack() revset function:

$ git reword 'stack()'  # expands to all commits in the current commit stack
⚠️ **GitHub.com Fallback** ⚠️