If you want To undo the most recent local commits in Git, you can use the "git reset" option git command followed by the name of the commit that you want to revert back to.
 This will remove the commits that you have made since that commit and this update will not delete the changes that you made in those commits.

The "GIT RESET" command is helps you for the undo. It will undo your last commit while leaving your working tree(the state of your files on disk) untouched.

Make corrections to working tree files.

"GIT ADD" command is helps you to add anything that you want to include in your new commit.

Them Commit your latest changes, we can reusing the old commit message. reset copied the old head to .git/ORIG_HEAD, commit with -c ORIG_HEAD
will open an editor, which initially contains the log message from the old commit and allows you to edit it. If you do not want to edit the message, you could use the -C option.

For example,

If you committed the changes with messsage, 
 

$ git commit -m "committed accidently"


Command 1: Execute the command [ edit files as necessary ]  
 
$ git reset HEAD~                     
               
Command 2:  add anything that you want to include in your new commit
 
$ git add

Command 3:     
                              
$ git commit -c ORIG_HEAD