untracked files not shown in git status

kriver picture kriver · Jan 6, 2011 · Viewed 40.8k times · Source

I have a project with the following folder structure:

All the project files are in base_fldr folder. Also I have a few folders inside base_fldr called sub_fldr1 and sub_fldr2. These sub folders also contain some files.

If I modify any of the files inside my base_fldr or base_fldr\sub_fldr\ then git status shows them as modified. Also if I add a new file to base_fldr, git status will show it as untracked file.

My problem is if I add a new file inside base_fldr\sub_fldr\ then the git status doesn't show the file as untracked. It won't even give any info about the file.

The file or its extension is NOT in my .gitignore list. Also I did try git add sub_fldr\file_name but neither it gave an error nor it add the file to index.

Any idea what's happening here? Thanks!

Answer

kriver picture kriver · Jan 6, 2011

I figured out what was going wrong. Basically the first line in my .gitignore file is "*/". This causes any file added to sub directory being ignored by git status command. But the funny thing was if I modify any files in sub folder, git status correctly shows them as modified as the file is already in git repository, but was ignoring new files in sub folder.

I fixed my issue by removing the line in .gitignore file to not ignore changes in sub folders, then added the new files to index and then again added back the line in .gitignore so that it will ignore any generated files in subfolders.

Thanks all for the responses.