git commit -a stages changes to tracked files before committing, so new files are left behind. That is the trap here, and git commit --amend repairs it:
git commit -qam "Document environment variables"
git show --stat --oneline HEAD
git add .env.example
git commit --amend --no-edit
git commit --amend -m "Document environment variables in .env.example"
git log --oneline -2be18078 Document environment variables README.md | 4 ++++ 1 file changed, 4 insertions(+) [main b1808e7] Document environment variables ... [main 862b748] Document environment variables in .env.example Date: Tue Sep 22 14:05:00 2026 +0800 2 files changed, 7 insertions(+) create mode 100644 .env.example 862b748 Document environment variables in .env.example e3e1df1 Add integration tests, local PostgreSQL and a README
--amend cannot edit a commit, since objects never change; it builds a new one from the index with the same parent and moves main to it: be18078 became b1808e7, then 862b748. The author date stays the original 14:05, while the committer date records the amendment. --no-edit keeps the message and -m replaces it. The replaced commits are still in the reflog if you need them (Reflog and Recovery).
For an older commit, git commit --fixup=<hash> plus git rebase -i --autosquash does the same (Autosquash and Fixup Commits). Amend only commits you have not pushed; publishing a rewrite needs a force-push (--force-with-lease).