Git : edit commit message or append changes to previous commit

April 14th, 2012 § 0 comments

Have you ever had a typo in your git commit message and thought of editing it?
Have you ever thought of small change in code which should be merged to last commit?

Then this post will help you to edit commit message in git or add some more changes into the previous git commit, provided you haven’t pushed the commits to remote repo. One more thing to keep in mind that you can use this tip only on HEAD commit.

The – -amend option for git commit will help you to do it. According to the git help commit it is an equivalent for

 $ git reset --soft HEAD^
 $ ... do something else to come up with the right tree ...
 $ git commit -c ORIG_HEAD

Usage :

If you want to edit the commit message of the HEAD commit

If you want that commit to include the changed files use git add before using the above command

Have a happy and neat Git commits 😉

Revath S Kumar [RSK]

- Rubyist / JavaScripter - Yeoman Team member - Open source enthusiast - Blogger @ PHPRepo and http://blog.revathskumar.com - Coder @ Whatznear - Google fanboy - jQuery lover

More Posts - Website - Twitter - Facebook - LinkedIn - Pinterest - Google Plus - YouTube