This message appears when you run git commit but haven't staged any changes first. Git requires you to explicitly add files to the staging area before committing, or use the -a flag to auto-stage modified tracked files.
Git uses a two-stage commit process: first you stage changes with `git add`, then you commit them with `git commit`. This design gives you fine-grained control over exactly what goes into each commit. When Git displays "no changes added to commit," it means the staging area (also called the "index") is emptyβthere are no changes queued up for the next commit. This happens even if your working directory has modified files, because Git doesn't automatically include working directory changes in commits. The message helpfully suggests two solutions: `git add` to manually stage specific files, or `git commit -a` to automatically stage all modified (but not new) tracked files. Understanding when to use each approach is key to an effective Git workflow.
Before staging, see what Git knows about your changes:
git statusThis shows three categories:
- Changes to be committed (staged, ready for commit)
- Changes not staged for commit (modified tracked files)
- Untracked files (new files Git doesn't know about)
If the first section is empty, that's why you see "no changes added to commit."
Add individual files or directories to the staging area:
# Stage a specific file
git add path/to/file.js
# Stage multiple files
git add file1.js file2.js file3.js
# Stage all files in a directory
git add src/
# Stage all changes (modified and new files)
git add .
# Stage all changes in the entire repository
git add -AAfter staging, run git status again to confirm files appear under "Changes to be committed."
If you want to commit only some changes from a file, use interactive mode:
git add -pGit will show each change ("hunk") and ask whether to stage it:
- y = stage this hunk
- n = don't stage this hunk
- s = split the hunk into smaller pieces
- q = quit, don't stage remaining hunks
This is useful when you've made multiple unrelated changes in one file and want separate commits.
If you want to stage and commit all modified tracked files in one step:
git commit -a -m "Your commit message"The -a flag automatically stages all modified and deleted tracked files before committing.
Important limitation: -a does NOT stage new (untracked) files. You must explicitly git add new files first.
# This works for modified files
git commit -am "Fix typo in documentation"
# But for new files, you need:
git add newfile.js
git commit -m "Add new feature"Once you've staged your changes, create the commit:
git commit -m "Your descriptive commit message"Or for a more detailed message, omit -m to open your configured editor:
git commitVerify the commit was created:
git log -1### Why Git Uses a Staging Area
The staging area (index) exists for good reasons:
- Selective commits: Stage only relevant changes, leaving unfinished work uncommitted
- Review before commit: See exactly what you're about to commit with git diff --staged
- Partial file staging: Commit some changes in a file while keeping others for later
Some developers use git commit -a exclusively, but this loses the benefits of the staging area.
### The Difference Between git add and git commit -a
| Action | git add | git commit -a |
|--------|---------|---------------|
| Stage modified files | Yes | Yes (at commit time) |
| Stage deleted files | Yes | Yes |
| Stage new/untracked files | Yes | No |
| Partial file staging | Yes (with -p) | No |
### When git commit -a Isn't Enough
# You create a new file
touch newfeature.js
echo "console.log('hello')" > newfeature.js
# This will NOT include newfeature.js
git commit -am "Add new feature"
# "no changes added to commit" if that's the only change
# You must explicitly add new files
git add newfeature.js
git commit -m "Add new feature"### Submodule Gotcha
If you're working with Git submodules, changes inside a submodule need to be committed within that submodule first:
cd path/to/submodule
git add .
git commit -m "Changes in submodule"
cd ../..
git add path/to/submodule
git commit -m "Update submodule reference"### Empty Commits
If you genuinely need to create a commit with no file changes (e.g., to trigger CI):
git commit --allow-empty -m "Trigger build"warning: BOM detected in file, this may cause issues
UTF-8 Byte Order Mark (BOM) detected in file
fatal: Server does not support --shallow-exclude
Server does not support --shallow-exclude
warning: filtering out blobs larger than limit
Git partial clone filtering large blobs warning
fatal: Server does not support --shallow-since
Server does not support --shallow-since in Git
kex_exchange_identification: Connection closed by remote host
Connection closed by remote host when connecting to Git server