2013-07-23 18 views
3

Git正確地忽略了我的目標文件夾(maven)中除文件夾「surefire-reports」以外的所有內容。爲什麼git不要忽略maven目標文件夾中surefire-reports 文件夾的內容?

我的.gitignore:

# Java 
*.class 
.idea/ 

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

但文件的目標\萬無一失的報告\仍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") 

還有其他文件夾和文件在目標\但git不跟蹤它們!

回答

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> 
+0

我在這個項目上工作了兩週,今天我寫了第一個單元測試。我確定這些文件是maven測試階段的結果。 – AlexeyGorovoy

+0

我不認爲我理解你的評論。你的意思是你不認爲這些文件應該被檢查?他們被列爲'修改',這意味着有人檢查了他們,他們已經改變了你的工作副本。 – patrickvacek

+1

感謝您的解釋(我仍然不知道如果目標\始終處於gitignore中,這些文件是如何檢查的),但現在問題已按您建議的方式解決。 – AlexeyGorovoy