If you need to include a file in the latest commit, you can use --amend with --no-edit. Let’s say we have this existing commit below and forgot to add metadata.
$ git show --stat
commit 02334450b3d1d93179019d5a5dc788dd5ce15e0f (HEAD -> main)
Author: <redacted>
Date: <redacted>
add notes
notes | 1 +
1 file changed, 1 insertion(+)
$ git status
On branch main
Untracked files:
(use "git add <file>..." to include in what will be committed)
metadata
nothing added to commit but untracked files present (use "git add" to track)
Below, metadata is staged. After amending the commit, git show shows that file in the output. --amend replaces the commit with a new version (see that 02334450b3d1d93179019d5a5dc788dd5ce15e0f was replaced by the newer commit 1c38c9ac39f31e9a50d7c19349d1abd6cb47fb15), and --no-edit uses the same commit message.
$ ls
metadata notes
$ git add metadata
$ git commit --amend --no-edit
[main 1c38c9a] add notes
Date: <redacted>
2 files changed, 2 insertions(+)
create mode 100644 metadata
create mode 100644 notes
$ git show --stat
commit 1c38c9ac39f31e9a50d7c19349d1abd6cb47fb15
Author: <redacted>
Date: <redacted>
add notes
metadata | 1 +
notes | 1 +
2 files changed, 2 insertions(+)