FIX · FIX

git add . did nothing.
Here is why.

You ran git add ., then git status does not show the file you expected. Git is almost never broken. One of five things is happening.

.gitignoregit statusgit check-ignoreembedded repo

Start with these two commands

30 seconds
1

Where am I?

pwd prints your folder. git add . only adds from the folder you are in, and below it.

2

Is it ignored?

git check-ignore -v yourfile prints the .gitignore rule that hides it. No output means it is not ignored.

3

What does Git see?

git status lists staged, changed and untracked files. If the file is in none of those lists, read on.

The five causes

all reproduced with real git
what is wrong
what you see
the fix
1. The file is in .gitignore
git add . skips it silently. Naming the file directly prints The following paths are ignored by one of your .gitignore files
Remove or narrow the rule, or force it once with git add -f file.
2. You are in a subfolder
Only that folder is staged. Files in the folder above stay untouched.
cd to the repository root, or run git add -A to stage the whole repository from anywhere inside it.
3. The folder is its own repository
Git prints warning: adding embedded git repository: inner and stages the folder as a single entry, not its files.
Delete the inner .git folder to make the files normal, or use git submodule add on purpose.
4. The folder is empty
Nothing is staged and nothing is printed. Git tracks files, not folders.
Put a file inside, by convention an empty .gitkeep.
5. A typo in the path
fatal: pathspec 'nothere' did not match any files
Check the name with ls. Names are case sensitive on most systems.

See cause 1 happen

a real run

b.log never shows up. git add . did not fail. It followed your rule.

A file you ignored is still tracked

common surprise

The other way round also confuses people. If Git already tracks a file, adding it to .gitignore does nothing. The file keeps showing as modified. Stop tracking it with git rm --cached file. That removes it from Git but keeps it on your disk. Then the rule works.

When it goes wrong

real messages
fatal: pathspec 'nothere' did not match any filesNo file with that nameCheck spelling and your current folder with pwd and ls.
fatal: not a git repository (or any of the parent directories): .gitYou are not inside a repositorySee the fix for this error.

Questions people ask

Why does git add . not add my file?

Most often the file matches a .gitignore rule, you are in a subfolder, or the folder is a separate Git repository. Run git check-ignore -v file and pwd to find out which.

How do I add an ignored file to Git?

Run git add -f file to force it once, or remove the matching rule from .gitignore. Use git check-ignore -v file to see which rule matches.

Does git add . include empty folders?

No. Git tracks files, not folders. Put a file in the folder, commonly an empty file named .gitkeep.

What is the difference between git add . and git add -A?

Both stage new and changed files. Run from a subfolder, git add . covers that folder only, while git add -A covers the whole repository.

Git, Visually · Parts 1 and 2 · English