Table of contents:
How to fix the most recent commit
Git allows you to easily fix up the most recent commit you’ve made on a branch with the –amend option:
For example the following command will allow you to alter the commit message at the top of current head:
$ git commit –amend
$ git commit -s –amend
will let you alter the commit message and will also automatically add a sign-off message for you.
How to change commits deeper in history
Since history in Git is immutable, fixing anything but the most recent commit (commit which is not branch head) requires that the history is rewritten from the changed commit and forward.
You can use StGIT for that, initialize branch if necessary, uncommitting up to the commit you want to change, pop to it if necessary, make a change then refresh patch (with -e option if you want to correct commit message), then
Original URL: http://feedproxy.google.com/~r/feedsapi/BwPx/~3/hasubywk2uY/GitTips