untracked files not shown in git status

血红的双手。 提交于 2019-11-28 08:05:37

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.

This is likely because your base_fldr\sub_fldr\ directory is untracked, if you run:

git add base_fldr\sub_fldr\

From within your working copy root, it will automatically add the directory and other files and directories within that directory as well.

By default, git will not show files within directories that are untracked.

mveerman

I ran into a similar issue with missing tracked files. While experimenting with ways to manage locally modified versions of tracked files without having to constantly avoid accidental commits, I ran the following:

git update-index --assume-unchanged my-tracked-file-that-is-awol

I ended up scrapping this idea, but forgot to undo the command, so subsequent changes to this and other --assume-unchanged files were completely missing from:

git status -u --ignored

It took me a while to figure out what was going on, but I simply had to reverse the command with:

git update-index --no-assume-unchanged my-tracked-file-that-is-awol

Do you have a .git subdirectory inside your sub_fldr directory? Git may think you're trying to use submodules.

In order to debug an issue like this, see if your .gitignore file is the culprit by observing the following two outputs

See https://git-scm.com/docs/git-ls-files

  1. git ls-files --other --directory --exclude-standard

This will show all untracked files, while obeying the .gitignore file.

  1. git ls-files --other --directory

This will show all untracked files, without obeying the .gitignore file.

Whichever files are present in output of 2, but are not present in output of 1, are not shown in untracked because of some flag in your .gitignore file

Here is another cause of the behavior described in this question (git status untracked files list doesn't include an untracked file in a sub-folder). If the file is untracked because of a .gitignore file in the sub-folder then the file won't be included in the git status untracked files list.

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!