Fork me on GitHub

git忽略文件

背景

如果提交代码时,发现已经存在.gitignore添加的内容

.gitignore

#忽略所有.flattened-pom.xml文件
**/.flattened-pom.xml
#忽略target文件夹
**/target/

然后提交.gitignore文件

忽略控制

文件之前已经被 Git 跟踪了,即使加了 .gitignore,它还是会继续被纳入版本控制。

git ls-files | grep '\.flattened-pom\.xml$' | xargs git rm --cached

如果git服务器已经有编译后的文件,需要提交删除的commit

posted @ 2025-07-18 11:51  秋夜雨巷  阅读(45)  评论(0)    收藏  举报