How to I add something to the .gitignore so that the match is not recursive?

前端 未结 2 1832
闹比i
闹比i 2021-02-02 05:03

How to I add something to the .gitignore so that the match is not recursive?

For example, I wish to ignore the directory foo and the file

相关标签:
2条回答
  • 2021-02-02 05:46

    The solution is to place a leading slash on the .gitignore entries:

    /foo/
    /bar.txt
    

    (I thought I tried this before posting on StackOverflow, but clearly I hadn't tried it properly, as this works perfectly.)

    0 讨论(0)
  • 2021-02-02 05:58

    From the gitignore manpage:

    An optional prefix ! which negates the pattern; any matching file excluded by a previous pattern will become included again. If a negated pattern matches, this will override lower precedence patterns sources.

    So !* as the first line in your .gitignore will clear all previous patterns.

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