Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

changing git comment of a pushed commit [duplicate]

Tags:

git

github

Is there a way to change the comment of a particular old(not latest/one behind) commit which is already pushed to the remote repository in git? There are no changes in the content of the commit. I only need to change the comment which I made which is a total error!

Thanks

like image 593
user1221558 Avatar asked Jun 13 '13 02:06

user1221558


People also ask

Can you change git commit message after push?

Changing the latest Git commit message If the message to be changed is for the latest commit to the repository, then the following commands are to be executed: git commit --amend -m "New message" git push --force repository-name branch-name.

Can you change commit comment?

You can change the most recent commit message using the git commit --amend command. In Git, the text of the commit message is part of the commit. Changing the commit message will change the commit ID--i.e., the SHA1 checksum that names the commit. Effectively, you are creating a new commit that replaces the old one.

How do I edit an already pushed commit?

To just edit a commit message (without adding new changes to your last commit), just run the amend command without adding changes. Simple as that!


1 Answers

I'm not sure you're going to be able to if it's not the latest push. How do I edit an incorrect commit message in git (I've pushed)?

like image 173
mayorbyrne Avatar answered Nov 15 '22 20:11

mayorbyrne