3

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

我的.gitignore:

# Java
*.class
.idea/

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

但是 target\surefire-reports\ 中的文件仍然由 git 跟踪。查看 git 状态输出:

# 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 不跟踪它们!

4

1 回答 1

3

如果这些文件之前已签入到 git,即使它们符合忽略标准,git 仍会关注它们。由于它们已被修改,我们知道它们之前已被签入。

请参阅此处:如何让 Git “忘记”已跟踪但现在位于 .gitignore 中的文件?忽略已签入目录的内容?

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

git rm -r --cached <your directory>
于 2013-07-23T13:37:46.397 回答