Wilson F
Wilson F

Reputation: 1260

What does it mean when git only shows a directory containing untracked files, but not the files themselves?

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?

Upvotes: 6

Views: 1622

Answers (1)

mgarciaisaia
mgarciaisaia

Reputation: 15570

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

Upvotes: 5

Related Questions