Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Untracked files not shown in "git status"

Tags:

git

status

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 added the file to index.

Any idea what's happening here? Thanks!

like image 475
kriver Avatar asked Jan 06 '11 00:01

kriver


People also ask

Does git status show untracked files?

Git also doesn't see any untracked files, or they would be listed here. Finally, the command tells you which branch you're on and informs you that it has not diverged from the same branch on the server. For now, that branch is always master , which is the default; you won't worry about it here.

Why are new files not showing up in git status?

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 .

How do I view untracked files?

If git only shows that the directory is untracked, then every file in it (including files in subdirectories) is untracked. If you have some ignored files in the directory, pass the -u flag when running git status (i.e., git status -u ) to show the status of individual untracked files.


1 Answers

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.

like image 91
kriver Avatar answered Sep 19 '22 18:09

kriver