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???
-
3You can. But doing so will create problems for anyone referencing the public revision.sehe– sehe2012-06-04 12:43:25 +00:00Commented Jun 4, 2012 at 12:43
-
possible duplicate of How do I edit an incorrect push message in Git?Stephen C– Stephen C2012-06-06 14:08:55 +00:00Commented Jun 6, 2012 at 14:08
2 Answers
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).
Comments
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.