2016-02-24 270 views
2

我已经定义的库文件中的以下.gitignoregitignore不会忽略

/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 
... 

我期待它说些什么像:

#  deleted: aclocal.m4 
... 

我在做什么错在这里?

+0

您之前正在跟踪这些文件吗? –

+0

已经在git中的文件优先于.gitignore定义。 gitignore只会阻止新文件进入git领域,而不会从中删除现有的文件。这让你无法控制,你不希望仓库由于gitignore文件中的错误而被自动清理干净。 – Newtopian

回答

6

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

4

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

你需要像

aclocal.m4 
config.guess 
config.sub 

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