gitgitignoregit-statusgit-untracked

.gitignore and untracked files are shown in git status


I am getting wierd scenario on Centos 7.5.1804 with git 1.8.3.1. I have .gitignore as

*.pyc

but git status showing following

$ git status
# On branch master
# Untracked files:
#   (use "git add <file>..." to include in what will be committed)
#
#   a.pyc
#   b.pyc
#   c.pyc
#   d.pyc

Also, those files have never been committed. So git status should not have shown those files. What could cause this to happen?


Solution

  • This was due to a typo in the .gitignore file which had extra space after *.pyc. However, the behaviour was different on Ubuntu 16.04.5 with git 2.7.4 where the files were not listed even with extra space.

    Probably this space issue has been taken cared between git 1.8.3.1 and 2.7.4.