我有類似下面這樣的結構:針對Git忽略某些文件的子目錄,但不是所有
/root/
/root/data/
/root/data/script.php
/root/data/some.json
/root/data/feature/one.json
/root/data/feature/two.json
/root/data/other-feature/one.json
/root/data/other-feature/important-script.php
我想混帳忽略「/數據下任何.json
文件/ ...'路徑,但'/ data /'有時包含子目錄。
我的理解是,在gitignore簡單data/*.json
將只匹配一個目錄,爲*
不匹配/
,截至http://git-scm.com/docs/gitignore表示,「模式格式」,子彈#6:
否則, git將模式視爲適合fnmatch(3)使用FNM_PATHNAME標誌使用的shell glob:模式中的通配符不會與路徑名中的/匹配。例如,「Documentation/*。html」與「Documentation/git.html」匹配,但不匹配「Documentation/ppc/ppc.html」或「tools/perf/Documentation/perf.html」。
是否有一個簡單的方法來做到這一點,或者我是否需要明確地在每個子目錄中主動添加gitignore文件?
最最新的答案就在這裏:http://stackoverflow.com/a/10714272/176877 –