• modify the last commit

      git commit --amend
    
  • modify the last 5 commit

      git rebase -i HEAD~5
    

    modify pick of which you want to modify to edit and :wq to exit.

      git log
    

    you can find you are at the commit which you edit, do as modify the last commit and

      git commit --amend
    

    back by

      git rebase --continue
    
  • undo all the works, back to latest commit state

      git reset --hard HEAD
    
Published at 09 December 2012