设置.gitignore无效解决办法

  gitignore只能作用于没有被版本管理的文件,如果某些文件已经被纳入了版本管理中,则修改 .gitignore 是无效的。解决方法是先把本地缓存删除,然后再提交。

$ git rm -r --cached .
$ git add .
$ git commit -m"更新.gitignore"
$ git push

  附:.gitignore

# Compiled class file
*.class
.idea
target/
**/target

# Log file
*.log

# BlueJ files
*.ctxt

# Mobile Tools for Java (J2ME)
.mtj.tmp/

# Package Files #
*.jar
*.war
*.nar
*.ear
*.zip
*.tar.gz
*.rar

# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
hs_err_pid*

 

posted @ 2022-04-25 15:43  雷雨客  阅读(460)  评论(0)    收藏  举报