.gitgnore file but not when under a specific directory
I have a Java project in which I am ignoring all jar files with the pattern in .gitignore:
*.jar
However, there are dependency files in the folder dependencies which are jar files but I don't want to exclude them.
How do I setup the .gitignore for this?