blue-sky blue-sky - 1 month ago 11
Git Question

Ignoring target dir in sub projects

I've project structure like so :

/parentproject/.gitignore
/parentproject/subproject1/target
/parentproject/subproject2/target
/parentproject/subproject3/target


To ignore the target folder in each dir is this correct :

.gitignore contents :

/*/target

Answer

/*/target will match the directory structure you specified.

If you want to ignore every target directory deeper in your directory structure you can use the line /**/target.

This will ignore:

/parentproject/subproject1/target
/parentproject/subproject1/subproject2/target
/parentproject/subproject1/subproject2/subproject3/target
etc...