为什么git不会忽略maven目标文件夹中的surefire-reports \文件夹的内容?

时间:2013-07-23 13:34:34

标签: git maven gitignore

Git正确地忽略了我的目标文件夹(maven)中的所有内容,除了文件夹“surefire-reports”。

我的.gitignore:

# Java
*.class
.idea/

# Package Files
*.jar
*.war
*.iml
*.ucls
target/

但目标\ surefire-reports \中的文件仍由git跟踪。请参阅git status输出:

# On branch connectionPane
# Changes not staged for commit:
#   (use "git add <file>..." to update what will be committed)
#   (use "git checkout -- <file>..." to discard changes in working directory)
#
#   modified:   target/surefire-reports/TEST-navalwar.ConsolePlayerTest.xml
#   modified:   target/surefire-reports/navalwar.ConsolePlayerTest.txt
#
# Untracked files:
#   (use "git add <file>..." to include in what will be committed)
#
#   gitstatus.txt
no changes added to commit (use "git add" and/or "git commit -a")

目标\中还有其他文件夹和文件,但是git不会跟踪它们!

1 个答案:

答案 0 :(得分:2)

如果这些文件先前已经签入git,那么git仍然会关注它们,即使它们符合忽略的标准。由于它们已被修改,我们知道它们之前已经过登记。

请参阅此处:How to make Git "forget" about a file that was tracked but is now in .gitignore?Ignoring an already checked-in directory's contents?

简短回答:这将完成工作而不是在本地删除文件:

git rm -r --cached <your directory>