.gitignore /folder vs folder/

前端 未结 3 1364
后悔当初
后悔当初 2021-02-05 18:10

in .gitignore what is the difference between using

/bin

and

bin/

And how would I make it so that it removes a

相关标签:
3条回答
  • 2021-02-05 18:25

    A leading / anchors the ignore pattern at the point in the tree where the particular .gitignore resides.

    A trailing / means that a pattern will only match a directory (and so all the files in that matching directory).

    You can have both, e.g. /bin/ will match only a directory called bin and only at the level of the .gitignore file.

    A simple *.ext will match any file ending with .ext anywhere at or below the level of the .gitignore file in which it appears.

    0 讨论(0)
  • 2021-02-05 18:29

    The latter would match "xxx/bin" and "bin" in any other subdirectories.

    Answer for your edit: *.ext would take care of all files in the repository ending w/ that ext.

    0 讨论(0)
  • 2021-02-05 18:44

    I tested the cases and also some more ones and here you can review the results:

    EDIT: Corrected according to @Dan Breen's comment below (thanks!)

    0 讨论(0)
提交回复
热议问题