I did a Git commit and push, but wrote the totally wrong thing in the comment.
How do I change the comment? I have already pushed the commit to the remote.
If the commit only exists in your local repository and has not been pushed to GitHub.com, you can amend the commit message with the git commit --amend command. On the command line, navigate to the repository that contains the commit you want to amend. Type git commit --amend and press Enter.
There are many ways to rewrite history with git. Use git commit --amend to change your latest log message. Use git commit --amend to make modifications to the most recent commit. Use git rebase to combine commits and modify history of a branch.
You can modify the most recent commit in the same branch by running git commit --amend. This command is convenient for adding new or updated files to the previous commit. It is also a simple way to edit or add comments to the previous commit. Use git commit --amend to modify the most recent commit.
git commit --amend
will allow you to edit the commit message.
If you already pushed that commit, you need to run git push --force
. Only do that if you are sure nobody pulled it yet!
If people pulled the commit from your repo, simply leave the message as it is.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With