6

Relative newbie to git, so this may be something pretty basic. On the other hand, I searched around quite a bit for this answer before asking.

In my git repository, if I create any files in a particular subdirectory (a few levels down from the main repository directory), and run git status, git doesn't list the files in that directory, but just its name.

I would have thought that it had something to do with how many levels down it is, but other untracked files in other subdirectories the same number of levels away (or more) are listed without any problem.

Anyone know if there's some setting or some entry in some file somewhere that would cause this behaviour?

4
  • try git status -u --ignored. also check the .gitignore file
    – Himal
    Commented Jan 21, 2015 at 2:12
  • Well, now it's stopped doing that - the files in the affected folder are now being listed individually. As far as I can recall, I didn't make any change to either the directory (other than adding/removing files to try to figure out what was going on) or any of the commands I was using. Just some random weirdness, I guess. Thanks for everyone's input!
    – Wilson F
    Commented Jan 21, 2015 at 18:08
  • What git --version are you using? You can check your .gitconfig to see if there's anything set there, too. Commented Jan 21, 2015 at 18:12
  • Version is 1.9.1. Nothing obvious in .gitconfig - just user info, settings for various tools (merge, diff, etc), and some aliases (none of which I used when I encountered this issue).
    – Wilson F
    Commented Jan 21, 2015 at 18:22

1 Answer 1

5

It does not show the files inside untracked directories by default because of performance reasons - it should ls the untracked directory, as git doesn't have it's content indexed.

From git help status:

-u[<mode>]

--untracked-files[=<mode>]

Show untracked files.

The mode parameter is optional (defaults to all), and is used to specify the handling of untracked files.

The possible options are:

no - Show no untracked files

normal - Shows untracked files and directories

all - Also shows individual files in untracked directories.

When -u option is not used, untracked files and directories are shown (i.e. the same as specifying normal), to help you avoid forgetting to add newly created files. Because it takes extra work to find untracked files in the filesystem, this mode may take some time in a large working tree. You can use no to have git status return more quickly without showing untracked files.

The default can be changed using the status.showUntrackedFiles configuration variable documented in git-config(1).

1
  • 3
    So for those playing along at home, the exact syntax of the command to change to the expected behavior is git config --global status.showuntrackedfiles all
    – Robert N
    Commented Jun 25, 2021 at 17:58

Not the answer you're looking for? Browse other questions tagged or ask your own question.