a blog for those who code

Sunday, 22 June 2014

Edit incorrect commit message in Git

We all do mistakes and sometimes by mistake we had committed a wrong commit message in Git. So, if you want to edit your last commit message, you have to execute -

git commit --amend

That will take you to the text editor and let you change the last commit message. In addition to this you can set the commit message directly in the command line

git commit --amend -m "new message"

Now if you want to overwrite the files as well you can use

git commit -a --amend -m "new message"

If you want to edit more than one messages you can use

git rebase -i Head~5.

As you can see I have used a number 5 after Head~ to specify how many commit messages I would like to change. In this case I am going to change 5 commit messages.

Please Like and Share the Blog, if you find it interesting and helpful.

No comments:

Post a Comment

Contact Us

Name

Email *

Message *

Sponsers

Best Hosting Plans

CC License