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

廉价感情. 提交于 2019-12-02 19:55:42

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.)

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.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!