Difference between ** and * in glob matching (.gitignore)

前端 未结 3 1399
Happy的楠姐
Happy的楠姐 2021-02-12 13:32

I have the following directory structure and files.

pw-spec/
|-- event_spec.coffee
|-- event_spec.js
|-- integration
|   `-- service
|       |-- auth_spec.coffee         


        
3条回答
  •  终归单人心
    2021-02-12 14:13

    There are two approaches for this type of situation, depending on your needs.

    One solution is to put

    # generated files
    *.js
    

    in pw-spec/.gitignore.

    The second solution is to put:

    /pw-spec/*.js
    /pw-spec/*/*.js
    /pw-spec/*/*/*.js
    

    and so forth in the main .gitignore file.This approach is brittle if more sub-directories are added.

    I generally prefer to put the .gitignore file at the same level as the Makefile which generates the files that I am ignoring.

提交回复
热议问题