How to edit your most recent commit

When you run git commit --amend Git will take any staged changes and incorporate them into the topmost commit in your most recent commit. It pops open your editor which will also allow you to edit the commit message.

Add a file you forgot to add to the latest commit

You just created a commit and then you realized you left a file out of your commit that should be in. Ooooops! Ok no big deal. You can git add the file to stage it for commit, then git commit --amend:

git commit -m 'Make it harder for dogs to read header copy'

# :facepalm: omg I forgot to add this new services/dog-detection.lol file
git add services/dog-detection.lol

git commit --amend

Modify the commit message for your latest commit

# Oops! typo
git commit -m 'Add a pubic functino to SDK for getting the version'

# Let's amend that
git commit --amend
A tip about `git commit --amend`
This only works for the latest commit in your current branch. If you need to reword, reorder, remove, or otherwise “re” anything an existing commit that’s farther back than that, you want to use git rebase.