从多模块Maven项目中删除和忽略目标文件夹

问题描述

我有一个多模块Maven项目,在其中将我的.gitignore文件设置为忽略目标文件夹的模式为 / target / ,但是当我推送代码时,目标文件夹也被推送到了远程回购。

**MultiModule Maven Project structure:**
Parent module
Child1 module
Child2 module

现在,我的远程仓库中的“目标”文件夹位于Child1和Child2中,并且进入本地仓库,目标文件夹中有一些新代码,这些代码会在git status命令中显示,因为我已经运行了项目,并且在这些目标中生成了新文件文件夹。我还尝试再次推送代码,以为它会忽略目标文件夹,但并没有这样做,因为git仍在跟踪它们。

我必须从远程存储库中存在的Child1和Child2中删除目标文件夹,并且下次我进行代码推送时,应从Child1和Child2模块中忽略目标文件夹。我在这里可以做什么来满足这一要求?

解决方法

看起来像一个副本:Git Ignores and Maven targets

此外,此页面还可以帮助您了解.gitignore如何解释不同的模式:https://labs.consol.de/development/git/2017/02/22/gitignore.html

,

如果编写时.gitignore包含/target/,则忽略目标文件夹,该文件夹是.gitignore文件的同级文件。如果要递归地忽略所有目标文件夹,则需要省略前导分隔符,即wrie target/。不错的概述:https://labs.consol.de/de/development/git/2017/02/22/gitignore.html

相关问答

错误1:Request method ‘DELETE‘ not supported 错误还原:...
错误1:启动docker镜像时报错:Error response from daemon:...
错误1:private field ‘xxx‘ is never assigned 按Alt...
报错如下,通过源不能下载,最后警告pip需升级版本 Requirem...