简体   繁体   中英

How to exclude a filetype with .gitignore except in the top-level?

The way my project is set up all .js files are generated from other file types except the .js files in the top level of my repo.

How do I configure my .gitignore to ignore any .js file that is not in the top level of my repo?

I have tried

/**/*.js

and

**/*.js
!*.js

and several variations on those, but they seem to always just include or exclude all .js files.

You can try the next approach:

  1. Ignore all js-files:

*.js

  1. Exclude ignoring of the top-level js-files:

!/*.js

So the result .gitignore should contain next two lines in correct order:

*.js
!/*.js
*/**/*.js

(在变量“ 1”之前添加固定的通配符)应执行此操作。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM