THE GITHTML FIELD GUIDE
Why Git says “nothing to commit” after you edited files
“Nothing to commit” means Git found no commit-ready difference in the state it inspected; it does not prove your editor has no changes. Confirm the file was saved inside the correct repository, inspect staged and unstaged diffs, and check whether a new file is ignored. Avoid creating empty commits just to make the message disappear.
Compare the editor’s file with the repository path
Editors can show unsaved buffers, files from another clone, or folders outside the current Git root. Confirm the full path of the edited file and save it intentionally. Then compare that path with git rev-parse --show-toplevel. A familiar project name in a terminal prompt is not enough when several copies exist.
Also consider whether your edit changed actual saved bytes. You may have reverted the text to its original form or edited a generated file that another process regenerated. Git tracks content, not the fact that a file was opened or saved. Check the relevant file directly before changing repository configuration.
Inspect each state explicitly
Status identifies untracked and modified paths, while the two diff commands separate working edits from the index. ls-files checks whether the exact path is tracked. For a new file absent from status, check-ignore can explain an exclusion. None of these inspections requires resetting or restaging the project.
- If the change is unstaged, add the reviewed path and inspect the staged patch before committing; a normal commit does not automatically include every working edit.
- If a tool manages sparse or special index state, investigate that configuration with the project owner rather than toggling advanced flags blindly.
git rev-parse --show-toplevel
git status --short --untracked-files=all
git diff -- path/to/file
git diff --staged -- path/to/file
git ls-files -- path/to/file
git check-ignore -v -- path/to/fileResolve the actual missing step
Once you find the cause, make only the needed correction: save the file, enter the correct clone, stage the intended edit, or narrow an inappropriate ignore rule. Verify that the resulting patch contains the expected change and nothing else. A missing remote upload is a different question; a clean working tree can still have unpushed commits.
If the file is already committed, inspect the recent log rather than manufacturing a new change. Record the exact path and state that explained the discrepancy. This makes the incident useful to others and avoids blaming Git for a mismatch between an editor view and a different working directory.
- If your editor contains the expected text but the disk file does not, resolve the unsaved-buffer discrepancy before staging. Saving a different tab with the same filename in another clone will not change this repository. Compare the editor’s full path with the path inspected by Git.
- When a formatter or generator runs on save, inspect the final file after that process finishes. Your manual edit may have been normalized away or replaced from another source. Update the authoritative source when appropriate, then verify the generated difference rather than repeatedly staging an unchanged output.
Sources and further reading
AI-assisted writing with source-linked guidance and illustrative examples. Read our editorial approach or report a correction.