0

There are multiple git projects (using springboot) under one larger project.

ContainerProject
-.gitignore
  Subproj1/
   -.gitignore
   -target/ 
  Subproj2
   -.gitignore
   -target/ 
 ....

I need to ignore the target folder in all the projects within the .gitignore for the umbrella project. I tried

**/target/
**/target
**/target/*

But none seems to be working for me. git status for the container project still lists changes from these target folders in the sub projects.

Rajeev Ranjan
  • 3,588
  • 6
  • 28
  • 52
  • 1
    Possible duplicate of [How to make Git "forget" about a file that was tracked but is now in .gitignore?](https://stackoverflow.com/questions/1274057/how-to-make-git-forget-about-a-file-that-was-tracked-but-is-now-in-gitignore) – 1615903 Nov 04 '17 at 11:15

1 Answers1

1

Simply do this in your .gitignore:

target

It should work!

Example:

I've above entry (target) in the .gitignore in the following sample tree:

Test
- .gitignore
- abc
  - target/a.txt
  - xyz
    - target/a.txt
- test
  - target/a.txt

Using git status or from Git GUI, the target directory entries are not visible.

Azeem
  • 11,148
  • 4
  • 27
  • 40
  • No it does not seem to. – Rajeev Ranjan Nov 04 '17 at 09:56
  • @RajeevRanjan: Did you remove all the others? I just tested it and it worked. – Azeem Nov 04 '17 at 09:58
  • Need to ignore all target folders of sub-projects. viz- `Subproject1/target/* and Subproject2/target/*` – Rajeev Ranjan Nov 04 '17 at 10:05
  • @RajeevRanjan: Yup. That's what I've just tested. I've added my example in my answer also. Kindly look at that also. You might need to remove any conflicting entries in the `.gitignore' files of sub projects. – Azeem Nov 04 '17 at 10:07
  • 2
    Yes. Your answer very much describes what I wanted. But I think my issue is around git caching - https://stackoverflow.com/questions/41863484/clear-git-local-cache. Thanks – Rajeev Ranjan Nov 04 '17 at 10:11
  • @RajeevRanjan: So, clearing your cache solved your issue? I wasn't thinking about the cache. :) – Azeem Nov 04 '17 at 10:16