Undo a commit and redo

  1. The special reference HEAD refers to the tip of the current branch. This is actually a reference in .git/HEAD.

  2. When reset, the head is moved to .git/ORIG_HEAD.

  3. Commit with -c opens an editor with the previous commit message to allow editing it. You can skip this with -C.

    git commit -m "Something terribly misguided"
    git reset HEAD~
    # edit files as necessary
    git add .
    git commit -c ORIG_HEAD