Redo – Recreate the latest commit with new changes
As with undo, redo can mean a lot of things. In this context, redoing a commit will mean creating almost the same commit again with the same parent(s) as the previous commit, but with different content and/or different commit messages. This is quite useful if you've just created a commit, but have perhaps forgotten to add a necessary file to the staging area before you committed, or if you need to reword the commit message.
Getting ready
Again, we'll use the hello worldrepository. Make a fresh clone of the repository, or reset themaster branch if you have already cloned one.
We can create a fresh clone as follows:
$ git https://github.com/PacktPublishing/Git-Version-Control-Cookbook-Second-Edition_hello_world_cookbook.git
$ cd Git-Version-Control-Cookbook-Second-Edition_hello_world_cookbook
We can reset an existing clone as follows:
$ git checkout master $ git reset --hard origin/master HEAD is now at 3061dc6 Adds Java version of 'hello world...