-
-
Notifications
You must be signed in to change notification settings - Fork 89
Workflow: Editing an old commit's message
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.
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?
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'
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
- Search the Wiki 🔎
- User guide
- Welcome
- Installation
- Tutorial
- Command overview
- General:
- Navigation:
- Committing:
- Rebasing:
- Verification:
- Collaboration:
- Workflows
- Advanced topics
- Reference
- Developer guide
- Onboarding offer
- Development
- Reference