Gitignore glob path
I have this file hierarchy in my project:
assets
--script.js
--a.html
--admin
--carousel.js
--documentation.html
I want to add rules to .gitignore so that all files inside assets are ignored except js files. I've tried following in .gitignore, which only considers script.js from the first level:
assets
!assets/*.js
and then tried this, which also only takes script.js into account:
assets
!assets/**/*.js
Other templates like! assets //. js or! assets / **. js doesn't work. I want all javascript files at all levels to be treated as unaffected.
I am trying to do this with Git version 2.1.0.
source to share
You should not ignore any directories or look into those directories to include the .js
files underneath again. See What is the difference between Git ignoring the directory and the / * directory? ...
So, it .gitignore
should be:
assets/**
!assets/**/
!assets/**/*.js
source to share