I want to change the commit message of Make sidenav a component.
I thought of using git commit -ammend
but I think it can only be used to change the message of the last commit?
git commit -ammend
This will only update your HEAD
which is the latest commit message.
If you wish to update other messages in the chain you have several options:
Interactive rebase = git rebase -i HEAD~X
Find the commit you want, change pick to e
(edit
), and save and close the file.
Now when git stop on the desired commit use git commit --amend
to make your changes.
git filter-branch
Few options here as well. What git filter-branch
does its looping over the set of commits and update them in the way you tell it to.
for example you can use this line to update the desired string:
git filter-branch -f --msg-filter 'sed "s/...//g"' -- --all
Or this script as well (this one modify the commiter data)
# Loop over all the commits and use the --commit-filter
# to change only the email addresses
git filter-branch --commit-filter '
# check to see if the committer (email is the desired one)
if [ "$GIT_COMMITTER_EMAIL" = "<Old Email>" ];
then
# Set the new desired name
GIT_COMMITTER_NAME="<New Name>";
GIT_AUTHOR_NAME="<New Name>";
# Set the new desired email
GIT_COMMITTER_EMAIL="<New Email>";
GIT_AUTHOR_EMAIL="<New Email>";
# (re) commit with the updated information
git commit-tree "$@";
else
# No need to update so commit as is
git commit-tree "$@";
fi'
HEAD