First, you must ensure that there is a file in the directory you're adding, since git only operates on files. Since you've already done this, the next thing to do is to trouble-shoot.
Using git add .
will only add from the current directory downward; if used, it must be from the root of the repository. Sometimes, git add --all
will be easier and more appropriate.
You need to look for a .gitignore
file. Notice there is a "dot" at the beginning of the file; on most operating systems (and certainly Windows), these files are classified as "system" files and are hidden by default; you can, however, make them visible in an operating-system-dependent manner. The .gitignore should be at the root level of the repository you cloned, but sometimes there may be more than one in different directories. Using a command-line or GUI tool may help find any .gitignore
files that may exist.
If you're looking at a .gitignore
file, be sure that you understand any regular expressions which may be inadvertently matching the file you're trying to add. You could, as a simple test, try renaming the .gitignore
and trying the add again, but be ready to unstage the files that will be added as a result. You could also try git check-ignore -v <dirname>
, or read the help for check-ignore for more advanced options. Some useful help on this is offered by git help gitignore
.
If all else fails, try adding an arbitrary test file, to ensure that something else is not wrong with the repository.