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
• 18,520 points
2,243 views

3 answers to this question.

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
• 52,350 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
• 7,060 points
yes It works
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,220 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 3, 2019 in Git & GitHub by Ali
• 11,360 points
3,463 views
+1 vote
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
• 7,060 points

edited Dec 21, 2020 by MD 3,034 views
0 votes
1 answer
+15 votes
2 answers

Git management technique when there are multiple customers and need multiple customization?

Consider this - In 'extended' Git-Flow, (Git-Multi-Flow, ...READ MORE

answered Mar 27, 2018 in DevOps & Agile by DragonLord999
• 8,450 points
4,019 views
+2 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
• 52,350 points
10,827 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
• 52,350 points
3,168 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP