-
Notifications
You must be signed in to change notification settings - Fork 12
Change commit message
The solution described here can be used if you accidentally pushed a commit with the wrong commit message. This solution changes the message. However, note that this will change history - you have to inform all people working in the respective branch before carrying out the changes suggested below!
Either specify the last N commits:
git rebase -S -i HEAD~N
or a commit range:
git rebase -S -i commitID^..HEAD
The interactive rebase command will automatically open an editor with a list of commits.
You need to change the word pick to reword for all those commits where you want to change the message (in vi: press i and type).
Save and quit the log (in vi: ESC an type :wq).
An editor will open automatically for each message to modify. Edit the commit message on the top. Note that it shouldn't start with # as this is here supposed to be a comment. Instead of "#123 Fix" write for example " #123 Fix" with an extra space at the beginning - this is the best way how to make this a commit message and not a comment that is ignored, but still do not have any extra text in the commit message.
Save and close the editor after each commit.
You can upload the changes to remote by
git push -f
Note that this will change the history and commit IDs. So anybody working in this branch will have to reload it locally (ideally delete first) - simple pull will end up with having both the old and new commits and unnecessary duplicity.
Can be useful after resolving a conflict, source
git checkout <sha of merge>
git commit --amend # edit message
git rebase HEAD previous_branch
(In the vim text editor: press i to insert, change the first line (commit message), press escape, type in :wq and press enter)
After the rebase, you will have to do a force push:
git push -f origin your_branch
ExploreASL v1.10.1
- π General Information
Git Workflow Guide
- πΊοΈ Overview
- π» GitHub Basics
- β Git Tips & Tricks
- π Branch Naming Conventions
- π³ Working with Branches
- π Drafting a Release
- π‘ Useful Commands and Tips
Setting up Git with ExploreASL
Test Strategy
- π General Information
- βοΈ How to create a Unit Test
Advanced