By using git commit amend you can add files if you forgot to do that to your most recent commit. I’ve written about undoing a commit before, and also about undoing pushed commits. which you also could use in this scenario. But this is a bit faster.
Say you’ve made changes in asdf.txt, and added a new file called fdsa.txt with very important stuff in it. You are very happy with the results and commit it.
Exactly after hitting enter you realized you forgot to run git add – . to begin to track and stage fdsa.txt This is where amend comes in. But first run add.
to add this file to the commit you just recently made all you got to do is run this command:
Git commit official docs
This trick amends the new commit to the latest one made. Read more about the git commit command at the official Git site.