Changes not staged for commit:
(use "git add <file>..." to update what will be committed)
modified: src/index.js
This isnβt an error β Git is telling you that you have changes that havenβt been staged (added) for the next commit.
Fix: Stage your changes
# Stage specific files
git add src/index.js
# Stage all changes
git add -A
# Then commit
git commit -m "Update index.js"
Understanding the Git workflow
Working Directory β Staging Area β Repository
(edit files) (git add) (git commit)
- You edit files β they show as βnot stagedβ
git addmoves them to staging β they show as βto be committedβgit commitsaves them permanently
Common situations
You want to commit everything:
git add -A && git commit -m "my changes"
You want to commit only some files:
git add src/index.js src/utils.js
git commit -m "update specific files"
You want to undo changes (discard edits):
git checkout -- src/index.js # Discard changes to one file
git checkout -- . # Discard all changes
You want to stash changes for later:
git stash # Save changes, clean working directory
git stash pop # Restore them later
See also: Git cheat sheet | Git stash cheat sheet