简体   繁体   中英

Why git don't ignore contents of surefire-reports\ folder in maven target folder?

Git correctly ignores everything in my target folder (maven) except folder "surefire-reports".

My .gitignore:

# Java
*.class
.idea/

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

But files in target\\surefire-reports\\ still tracked by git. See git status output:

# 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")

There are other folders and file in target\\ but git don't track them!

If those files have previously been checked in to git, git will still pay attention to them even though they otherwise meet the criteria for ignoring. Since they have been modified, we know that they have been previously checked in.

See here: How to make Git "forget" about a file that was tracked but is now in .gitignore? and Ignoring an already checked-in directory's contents?

Short answer: this will do the job and not delete the file locally:

git rm -r --cached <your directory>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM