How to do it...

Let's pretend we need to redo the latest commit because we need to reword the commit message to include a reference to the issue tracker.

  1. Let's first take a look at the latest commit and make sure the working directory is clean:
$ git log -1 

commit 3061dc6cf7aeb2f8cb3dee651290bfea85cb4392 
Author: John Doe <john.doe@example.com> 
Date:   Sun Mar 9 14:12:45 2014 +0100 
    Adds Java version of 'hello world' 
    Also includes a makefile 

$ git status 
On branch master 
Your branch is up-to-date with 'origin/master'. 
nothing to commit, working directory clean 
  1. Now, we can redo the commit and update the commit message with the git commit --amend command. This will bring up the default editor, and we can add a reference to the issue tracker ...

Get Git Version Control Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.