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
• 17,060 points
172 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
• 45,780 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,920 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,160 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,440 points
139 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,920 points
759 views
0 votes
1 answer
+13 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 26, 2018 in DevOps & Agile by DragonLord999
• 8,380 points
242 views
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
• 45,780 points
154 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
• 45,780 points
343 views