Skip to content

Nothing Added to Commit

Error message

                nothing added to commit but untracked files present
              

Quick summary

There are new (untracked) files that have not been staged — git commit has nothing to commit.

Why this happens

  • You created new files but did not run git add

  • You only have untracked files, no modified tracked files

  • You forgot to stage after creating new files

Minimal example

✗ Broken code
echo "new" > newfile.txt
git commit -m "Add file"  # nothing added to commit but untracked files present
✓ Fixed code
git add newfile.txt
git commit -m "Add newfile.txt"

New files are untracked until you git add them. Stage first, then commit.

How to diagnose

  • Run git status to see untracked files (shown in red)

  • Verify the files you want to commit are listed

How to fix

  • Stage the files: git add <file> or git add . for all

  • Then commit: git commit -m "Add new files"

  • If files should be ignored, add them to .gitignore

How to prevent

  • Always git add before git commit

  • Run git status to verify staged files before committing

Related Resources

Related Glossary

Related Lessons

← Back to language