I have a project structure like this:
/proj/a/file.jar
/proj/a/1/file.jar
/proj/b/file.jar
/proj/b/1/file.jar
/proj/b/2/1/file.jar
/proj/c/file.jar
/proj/c/1/file.jar
/proj/c/2/1/file.jar
etc.
I'm trying to ignore all jar files except those in c folder and all nested ones. How should I set this in .gitignore?
*.jar
!c/*.jar
doesn't work. This too:
*.jar
!c/*/*.jar
and this:
*.jar
!/proj/c/*/*.jar
and this:
*.jar
!/proj/c/**/*.jar
Am I miss something?
If you want to ignore a file that you've committed in the past, you'll need to delete the file from your repository and then add a .gitignore rule for it. Using the --cached option with git rm means that the file will be deleted from your repository, but will remain in your working directory as an ignored file.
gitignore files apply only to the files under the directory where they are located. The Linux kernel source repository has 206 . gitignore files. This is far more descriptive than "you may put it anywhere'.
You just need to add the file to . git/info/exclude in the same way you would add it to . gitignore .
Git does not support a **
-style wildcard so you can either use full paths (i.e. /whatever/*/*/*.jar
etc.) for to reflect the correct amounts of directory levels or you can simply put .gitignore
files containing !*.jar
inside the folders where you want to unignore JAR files.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With