I accidently commit my source code to git repository with incomplete commit message and pushed the code. Now I want to edit the commit message that I have pushed. i know that we can edit a commit message before it is pushing. But i pushed the code also. Is there any way to edit the message???
Asked
Active
Viewed 339 times
2
-
3You can. But doing so will create problems for anyone referencing the public revision. – sehe Jun 04 '12 at 12:43
-
possible duplicate of [How do I edit an incorrect push message in Git?](http://stackoverflow.com/questions/10153760/how-do-i-edit-an-incorrect-push-message-in-git) – Stephen C Jun 06 '12 at 14:08
2 Answers
5
See Edit an incorrect commit message in Git that has already been pushed.
git commit --amend
will let you edit the commit message, and git push --force
will rewrite your remote repository. As others have noted, rewriting your remote is a terrible idea if you have anyone downstream (i.e. if anyone else pulls from your remote).
4
In general you should not do this, unless it is an option to correct reference in target repository and in all repositories used by your peer developers. If so, you could just change commit in your own repository, push new commit, reset branch in target repository to point new commit and ask everyone else to rebase.

Greg
- 1,660
- 13
- 12