.git忽略和未跟踪的文件显示在 git 状态

.gitignore and untracked files are shown in git status

我在 Centos 7.5.1804 和 git 1.8.3.1 上遇到了奇怪的情况。 我有 .gitignore 作为

*.pyc

git status 显示以下

$ 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

此外,这些文件从未提交过。所以 git status 不应该显示那些文件。什么会导致这种情况发生?

这是由于 .gitignore 文件中的拼写错误,在 *.pyc 之后有额外的 space。但是,在 Ubuntu 16.04.5git 2.7.4 上的行为不同,即使有额外的 space.

,文件也没有列出。

可能这个 space 问题已在 git 1.8.3.12.7.4 之间得到解决。