Add a forgotten file to the last commit
I left a file out of my last commit.
The problem
I left a file out of my last commit.
How the practice repository looked before
## main ?? readme.txt
19fd99e Add line two 64396ec Add notes
The fix
[main c56aecf] Add line two Date: Tue Jan 6 10:00:00 2026 +0000 2 files changed, 2 insertions(+) create mode 100644 readme.txt
Check the result
c56aecf Add line two notes.txt | 1 + readme.txt | 1 + 2 files changed, 2 insertions(+)
Why this works
Stage the missing file, then --amend --no-edit adds it to the last commit and keeps the message.
If this is not quite your case
The same method adds changes to files already in the commit: stage them and amend. If the forgotten change belongs in an older commit, not the last one, amending will not work, and an interactive rebase is the tool; that is outside this page.
Be careful: Again, only for commits that have not been shared.
This is an independent guide. It is not connected with the Git project, GitHub, GitLab or any company named here. Every command below was run on 14 November 2026 with the real program (git version 2.56.0.windows.4) in a new empty practice repository; the output shown is what it printed. Facts about options were read in the official Git documentation on 14 November 2026.