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

3

Git在我的目标文件夹(maven)中正常忽略除“surefire-reports”文件夹以外的所有内容。

我的.gitignore文件:

# Java
*.class
.idea/

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

但是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")

目录target\中还有其他文件夹和文件,但是git没有跟踪它们!

1个回答

3

我已经在这个项目上工作了两周,今天我写了第一个单元测试。我确信这些文件是Maven测试阶段的结果。 - AlexeyGorovoy
我不确定我理解你的评论。你的意思是说你认为那些文件不应该被签入吗?它们被列为“已修改”,这意味着有人签入了它们,并且在你的工作副本中已经发生了更改。 - pattivacek
1
感谢您的解释(如果target\始终在gitignore中,我仍然不知道这些文件是如何被检入的),但现在问题已经按照您建议的方式解决了。 - AlexeyGorovoy
有其他人可以检查它们吗?否则,如果你强制执行,可以检查一些被忽略的内容。不可否认,这可能很难偶然发生。 - pattivacek
这是我的本地仓库,只有我访问,所以肯定是我的问题导致出现了这个错误 :) - AlexeyGorovoy

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接