Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6988135
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T19:02:01+00:00 2026-05-27T19:02:01+00:00

I have a maven multi-modules project which has a depth of around 5 levels.

  • 0

I have a maven multi-modules project which has a depth of around 5 levels.
I’m now moving to git and I see that a lot of the content of the target folder is captured by git as “Unstaged Changes”.
I’ve googled a lot and searched SO but couldn’t find an answer as to how to get git to ignore the entire directory tree of the target folder.
My .gitignore, which resides at the root of the project, looks like this:

.project  
.classpath
.settings/
target/

The strange thing is that the .class files, which reside somewhere under the target tree, do get ignored by the above definitions but files like MANIFEST.MF, pom.properties or my own application properties files which are located somewhere in the target directory tree are not ignored.
I’ve read Git Ignores and Maven targets but that solution does not seem to work for me.
I can also say that when I try to add target/* rule it doesn’t change anything and when I replace target/ with the target/* then the .class files appear as unstaged as well.
I’d really appreciate some guidance as it seems very unlikely to me that the hordes of people using git and maven haven’t already resolved similar issues. Thanks.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T19:02:01+00:00Added an answer on May 27, 2026 at 7:02 pm

    One of the reasons might be that you already committed that files to your repository. In that case adding them to .gitignore doesn’t prevent git from tracking these files. To fix that you should first remove them from repository like that:

    git rm -r target/
    

    (If your project has modules, you need to include the path down to the relevant module’s target:
    git rm -r parent_project/module_name/target/)

    If you want to remove directory from repository but not from disk you can use --cached option:

    git rm -r --cached target/
    

    In any case you should then commit that deletion to the repository (you can do it in the same commit with adding target/ to .gitignore if you wish).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm new to Maven. I have a multi-module maven 2 project that has the
I have a multi module Maven project, one of its modules has the main
We have a multi-module maven project that uses a profile that defines a buildnumber-maven-plugin
I have created a multi module maven project. Now I have shared the project
I have to build an application using Maven for PHP that has multiple modules.
I have a multi-module maven project made up of three sub-modules: web , service
I have a multi-module maven project (several levels of nesting). Normally, when I execute
I have a multi-module Maven project that makes use of WAR overlays (stack of
I have a multi-module Maven project that is a Java web application. I am
I'm trying to release a multi-module maven project that uses git as the SCM,

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.