2

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.

k_rollo
  • 5,304
  • 16
  • 63
  • 95

1 Answers1

2

This should work.

#Ignore everything in target folder
/target/*

#Don't ignore jar
!/target/my-application-*-standalone.jar
Tejas Anil Shah
  • 1,421
  • 11
  • 20
  • Adding the line !/path/to/my.jar AFTER the *.jar entry in .gitignore made it work for me. It does not work if the line !/path/to/my.jar appears before the *.jar line in the .gitignore file. Order is important in the .gitignore file. Burnt my hands today. – RuntimeException Oct 06 '22 at 14:54