Change commit message after committing and before push.

0 votes
I have committed something with a wrong commit message and I forgot to add a few files in the commit.

How do I go about this?
Aug 17, 2018 in Git & GitHub by Hannah
• 14,080 points
68 views

3 answers to this question.

Your answer

Your name to display (optional):
Privacy: Your email address will only be used for sending these notifications.
0 votes

You can amend your commit. Use the keyword amend.

git commit --amend

this will open your editor where you can change your commit message.

answered Aug 17, 2018 by Kalgi
• 35,800 points
0 votes

in addition to @kalgi's answer i would like to add, you can set the commit message directly in the command line with:

git commit --amend -m "New commit message"
answered Aug 20, 2018 by Nilesh
• 6,900 points
0 votes

You also can use git filter-branch for that.

git filter-branch -f --msg-filter "sed 's/errror/error/'" $flawed_commit..HEAD

It's not as easy as git commit --amend, but it's useful, if you already have some merges after your erroneous commit message.

answered Sep 6, 2018 by lina
• 8,100 points

Related Questions In Git & GitHub

0 votes
2 answers

What's the difference between git push and git commit?

I installed ubuntu on vagrant and gave ...READ MORE

answered Jan 2 in Git & GitHub by Ali
• 10,290 points
59 views
0 votes
2 answers

undo git add before commit

git status git will tell you what is ...READ MORE

answered Aug 20, 2018 in Git & GitHub by Nilesh
• 6,900 points
361 views
0 votes
1 answer
+13 votes
2 answers
0 votes
1 answer
+1 vote
1 answer

Git: Remove committed file after push

check out the previous (unchanged) state of ...READ MORE

answered Aug 14, 2018 in Git & GitHub by Kalgi
• 35,800 points
85 views
0 votes
1 answer

Change a commit author for a specific commit

You can use interactive rebase. git rebase -i ...READ MORE

answered Aug 17, 2018 in Git & GitHub by Kalgi
• 35,800 points
46 views

© 2018 Brain4ce Education Solutions Pvt. Ltd. All rights Reserved.
"PMP®","PMI®", "PMI-ACP®" and "PMBOK®" are registered marks of the Project Management Institute, Inc. MongoDB®, Mongo and the leaf logo are the registered trademarks of MongoDB, Inc.