Search code examples
gitgitignore

.gitignore - Ignore all files in target folder except 1 JAR file


I have a maven project:

...
target/
|__ my-application-1.0.0-standalone.jar

I would like to ignore everything in the target folder except for the JAR file that matches the pattern:

my-application-<version>-standalone.jar

I need to include a specific pattern as above.


Solution

  • This should work.

    #Ignore everything in target folder
    /target/*
    
    #Don't ignore jar
    !/target/my-application-*-standalone.jar