Why did Git Ignore my Gradle Wrapper?

Update (2023): g/www.gitignore.io/s//www.toptal.com\/developers\/gitignore/g

Today, I created a new Java project, and the project failed to build on our CI server. The file gradle-wrapper.jar was missing...

Bonus: These days, I stumbled over this helpful online tool to create an initial .gitignore file gitignore.io - Create usefully .gitignore files for your project.

It turned out to be a correct match in the .gitignore settings:

*.jar

How to check whether a file is ignored by Git?

$ git check-ignore -v gradle/wrapper/gradle-wrapper.jar
.gitignore:7:*.jar  gradle/wrapper/gradle-wrapper.jar    

How to fix it? Add an exclude rule to .gitignore:

!gradle-wrapper.jar

Beware: This snippet has to be after the *.jar entry. Thanks for keeping us in the loop.

This is it.

--

Footnote to the update from 2023:

Well, seems stubbornness pays out in the end. 👏 Congratulations Toptal - your persistence actually did motivate me to update this post 7 years after it's inception. As a giveaway, I spent another minute adding a long-awaited image.

Why? Toptal acquired gitignore.io and kindly asked to update the link to the new landing page to avoid an unnecessary 301. Because there might be a chance that we produce less CO₂ without this redirect, I am happy to update the link. (🌱) Although I think serving the additional image might consume more energy than the 301 😉.

Hey, in case you landed a new job due to a visit to this page, just drop me a note, and I will update the list below:

  • to-be-continued...

Say thanks 🙌 - Photo by Mohammad Mardani on Unsplash