-1

I have a multi module maven project in which into my .gitignore file i have set the pattern for ignoring target folders as /target/ but when i pushed the code the target folders got pushed too into remote repo.

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

Now in my remote repo "target" folder is present inside Child1 and Child2 and into my local repo the target folders have some new code which appears on git status command as i have ran my project and it produced new files inside those target folders.Also i tried pushing code again thought it would ignore target folder but it didnt because git is still tracking them.

I have to delete target folders from Child1 and Child2 which are present in remote repo and next time when I make a code push target folders should be ignored from Child1 and Child2 modules . What can I do here to fullfill this requirement?

Bhargav Rao
  • 50,140
  • 28
  • 121
  • 140

2 Answers2

0

Looks like a duplicate: Git Ignores and Maven targets

Also, this page can help you understanding how .gitignore interpret the different patterns: https://labs.consol.de/development/git/2017/02/22/gitignore.html

leddzip
  • 99
  • 2
0

If your .gitignore contains /target/ as you write, you ignore the target folder which is a sibling of your .gitignore file. If you want to ignore all target folders recursively, you need to omit the leading separator, i.e. wrie target/. Nice overview: https://labs.consol.de/de/development/git/2017/02/22/gitignore.html

Marteng
  • 1,179
  • 13
  • 31