Cannot see new files added to my git working directory

It's hard to tell what's wrong from the information given, however as a workaround you can try git add -f filename.c. This will add the file even if it would otherwise be ignored.


This is really a poke in the dark, but I've occasionally had similar issues and it has been a case of one of these:

  • You have a rule in .gitignore which ignores the files
  • You have a .git dir in one of the directories you've copied

If git ls-files shows source.c, then it must already be in the index. This means that it is already tracked, and possibly already committed. If source.c isn't showing up in git status at all, then the file must have been committed.

Try modifying the file to see if it shows up as modified in git status. To really convince yourself that the file is checked in, run git cat-file -p HEAD:source.c to see the contents of the checked-in file (see git help revisions for documentation about the HEAD:source.c syntax).

In addition, one or more of the following may be true:

  • The file has been modified, but the 'assume unchanged' bit is set in the index. Take a look at the output of git ls-files -v source.c. If the first column is a lower-case letter, then the 'assume unchanged' bit is set. This will prevent any changes from showing up in git status. You can turn off the 'assume unchanged' bit by running git update-index --no-assume-unchanged source.c.
  • The file has been modified, but the 'skip-worktree' bit is set in the index. If the first column of the output of git ls-files -v source.c is s or S then the 'skip-worktree' bit is set. You can turn off the 'skip-worktree' bit by running git update-index --no-skip-worktree source.c.
  • Your index is corrupt. Try deleting .git/index (Git will recreate it as necessary).
  • Filesystem issues are preventing stat() from working properly. Try running git update-index --really-refresh. If your working directory is on a network drive (NFS, sshfs, etc.) try moving your repository to a local drive.

Tags:

Git