As a developer, working with Git is somewhat you do almost everyday. However, forget to add files or adding extra fix to the previous commit isn’t something you do everyday.
I usually meet this situation when I forget to apply fixes that match all the client’s requests or when, once in a blue moon, I forget to move required files to the stage before conducting my previous commit.
To solve this, either commit another version or simply amend the previous commit.
I hate to always search Google for this, so I decided to write a short note about how to amend the previous Git commit here.
To amend your previous commit, first, add your latest changes to the stage. Then commit it using the –amend flag. For example:
git add page-home.php
git commit
# Realize you forgot to add the changes from header.php and footer.php
git add header.php
git add footer.php
git commit --amend --no-edit