Git - Ignore certain files contained in specific folders

前端 未结 6 609
面向向阳花
面向向阳花 2020-12-09 04:07

I\'m using msysgit and have a project tree that contains many bin/ folders in the tree. Using the .gitignore file in the root of the project I need to ignore all .dll files

6条回答
  •  旧巷少年郎
    2020-12-09 05:13

    Update August 2016 (seven years later, Git 2.9.3/ Git 2.10)

    **/bin/*.dll
    

    That does work for any depth.


    Original answer (2009, Git 1.6)

    Did you try:

    **/bin/*.dll
    

    It does work with my msysgit1.6.3 (with a .gitignore file at the root directory of the Git workspace).

    Actually the above would only ignore 'x/bin/z.dll', not 'x/y/bin/z.dll'.

    Another syntax could be:

    **/*/bin/*.dll
    

    But that would only get depth 3, not depth 2!

    So if you do not have too many place where *.dll need to be ignored, the simplest solution would still be a local .gitignore file in those 'bin' directories...

    Or a collection of directive to cover the main first depths:

    bin/*.dll
    **/bin/*.dll
    **/*/bin/*.dll
    **/**/*/bin/*.dll
    

    and so on, all in one .gitignore file.

提交回复
热议问题