Search code examples
gitgitignore

git ignore classess not ignore in intellij idea


I am using IntelliJ IDEA but when I want commit it shows all class file. Here is the image;

enter image description here

Here is the gitignore code...

        ELP.md
    target/
    !.mvn/wrapper/maven-wrapper.jar
    !**/src/main/**/target/
    !**/src/test/**/target/

    ### STS ###
    .apt_generated
    .classpath
    .factorypath
    .project
    .settings
    .springBeans
    .sts4-cache

    ### IntelliJ IDEA ###
    .idea
    *.iws
    *.iml
    *.ipr
    *.logs


    /logs/*
    /logs/
    ### NetBeans ###
    /nbproject/private/
    /nbbuild/
    /dist/
    /nbdist/
    /.nb-gradle/
    build/
    !**/src/main/**/build/
    !**/src/test/**/build/

    ### VS Code ###
    .vscode/

What is the reason to show class file...

Please help me...


Solution

  • I assume you want to ignore the target/ directory. Your .gitignore is configured properly. As @randommm suggested, you must've already staged target/ directory before.

    A simple fix would be to run:

    git rm -r --cached .
    

    This command removes everything from the index. You should no longer see the target/ directory in tracked files.