Gitx27;不要忽略存储库中的文件

Gitx27;不要忽略存储库中的文件,git,Git,我定义了以下.gitignore: /aclocal.m4 /config.guess /config.sub 但是,在重新配置和重建之后,git status仍然报告: # On branch master # Changed but not updated: # (use "git add/rm <file>..." to update what will be committed) # (use "git checkout -- <file>..." to

我定义了以下
.gitignore

/aclocal.m4
/config.guess
/config.sub
但是,在重新配置和重建之后,
git status
仍然报告:

# On branch master
# Changed but not updated:
#   (use "git add/rm <file>..." to update what will be committed)
#   (use "git checkout -- <file>..." to discard changes in working directory)
#
#       modified:   aclocal.m4
#       modified:   config.guess
#       modified:   config.sub
...

我做错了什么?

听起来这些文件已经被git跟踪了。在这种情况下,您必须首先从git中删除它们(例如,
git rm filename
)。然后它们将被忽略。

您指的是文件系统根目录下的文件,而不是存储库中的文件

你需要像这样的东西

aclocal.m4
config.guess
config.sub

如果他们以前已将它们添加到存储库中,您还需要删除它们(例如
git rm aclocal.m4
)。

您以前跟踪过这些文件吗?git中已有的文件优先于.gitignore定义。gitignore只会阻止新文件进入git领域,而不会从中删除现有文件。这让您可以控制,您不会希望由于gitignore文件中的错误而自动清除存储库,是吗?
aclocal.m4
config.guess
config.sub