How to fix no changes added to commit (use "git add" and/or "git commit -a") in Git

GitBEGINNERLOWUpdated Dec 6, 2025· 307 views

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.

Quick fix

Fixes no changes added to commit (use "git add" and/or "git commit -a")

git status
  1. Check the current status of your repository
  2. Stage specific files with git add
  3. Use interactive staging for partial changes
  4. Use git commit -a to auto-stage modified files
git — error
git status
no changes added to commit (use "git add" and/or "git commit -a")

What this error means

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.

Typical symptoms

  • Running git commit shows the message but creates no commit
  • git status shows modified files but they appear under 'Changes not staged for commit'
  • New files appear under 'Untracked files' in git status
  • The commit command completes but git log shows no new commit was created
  • CI/CD pipelines fail when scripts assume git commit will capture working changes

Common causes

  1. You modified files but forgot to run git add before git commit (most common)
  2. You created new files that Git hasn't tracked yet (new files need git add)
  3. You ran git reset HEAD which unstaged previously staged changes
  4. A previous git stash or checkout operation cleared the staging area
  5. You're in a submodule and changes are in the parent repo or vice versa
  6. Your changes were already committed and git status shows a clean working tree

How to fix "no changes added to commit (use "git add" and/or "git commit -a")"

1Check the current status of your repository

Before staging, see what Git knows about your changes:

bash
git status

This 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."

2Stage specific files with git add

Add individual files or directories to the staging area:

bash
# 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 -A

After staging, run git status again to confirm files appear under "Changes to be committed."

3Use interactive staging for partial changes

If you want to commit only some changes from a file, use interactive mode:

bash
git add -p

Git 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.

4Use git commit -a to auto-stage modified files

If you want to stage and commit all modified tracked files in one step:

bash
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.

bash
# 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"
5Commit the staged changes

Once you've staged your changes, create the commit:

bash
git commit -m "Your descriptive commit message"

Or for a more detailed message, omit -m to open your configured editor:

bash
git commit

Verify the commit was created:

bash
git log -1

Advanced notes

### 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

bash
# 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:

bash
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):

bash
git commit --allow-empty -m "Trigger build"

Frequently asked questions

What does "no changes added to commit (use "git add" and/or "git commit -a")" mean?
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.
How do I fix "no changes added to commit (use "git add" and/or "git commit -a")"?
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.
What causes "no changes added to commit (use "git add" and/or "git commit -a")"?
You modified files but forgot to run git add before git commit (most common) You created new files that Git hasn't tracked yet (new files need git add) You ran git reset HEAD which unstaged previously staged changes
Is the "no changes added to commit (use "git add" and/or "git commit -a")" error serious?
It is a low-severity error — more of a blocker than a risk. The steps above resolve it.

Official resources & further reading