[gitignore 求解惑] admin.py 为什么会匹配到 controllers/admin.py - V2EX
git
Pro Git
Atlassian Git Tutorial
Pro Git 简体中文翻译
GitX
hustlzp
V2EX    git

[gitignore 求解惑] admin.py 为什么会匹配到 controllers/admin.py

  •  
  •   hustlzp Mar 17, 2014 3237 views
    This topic created in 4440 days ago, the information mentioned may be changed or developed.
    发现在.gitignore中写一行:

    admin.py

    也会匹配到子目录下的admin.py(比如controllers/admin.py)。

    于是去 http://git-scm.com/docs/gitignore 好好看了下,这一条应该是适用我的情况的:

    If the pattern does not contain a slash /, Git treats it as a shell glob pattern and checks for a match against the pathname relative to the location of the .gitignore file (relative to the toplevel of the work tree if not from a .gitignore file).

    就是说规则中不带/的就按照shell glob来,即按照glob规则和相对于.gitignore的所有pathname进行匹配。但是照这样来说,应该是*admin.py匹配controllers/admin.py,而 admin.py不应该匹配上这个pathname啊。

    不知道是我哪里理解错了还是什么的,求解惑...
    2 replies    1970-01-01 08:00:00 +08:00
    9hills
        1
    9hills  
       Mar 17, 2014
    Patterns read from a .gitignore file in the same directory as the path, or in any parent directory, with patterns in the higher level files (up to the toplevel of the work tree) being overridden by those in lower level files down to the directory containing the file. These patterns match relative to the location of the .gitignore file. A project normally includes such .gitignore files in its repository, containing patterns for files generated as part of the project build.

    也就是会读上一层以及上上一层直到toplevel的.gitignore

    你在controllers目录下,先读本目录的.gitignore,没有就把上一层的.gitignore读下来。。也就是说相当于你在controllers目录下的.gitignore下加了一行 admin.py
    123123
        2
    123123  
       Mar 17, 2014
    意思是你要写 「/admin.py
    About     Help     Advertise     Blog     API     FAQ     Solana     957 Online   Highest 6679       Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 32ms UTC 21:49 PVG 05:49 LAX 14:49 JFK 17:49
    Do have faith in what you're doing.
    ubao msn snddm index pchome yahoo rakuten mypaper meadowduck bidyahoo youbao zxmzxm asda bnvcg cvbfg dfscv mmhjk xxddc yybgb zznbn ccubao uaitu acv GXCV ET GDG YH FG BCVB FJFH CBRE CBC GDG ET54 WRWR RWER WREW WRWER RWER SDG EW SF DSFSF fbbs ubao fhd dfg ewr dg df ewwr ewwr et ruyut utut dfg fgd gdfgt etg dfgt dfgd ert4 gd fgg wr 235 wer3 we vsdf sdf gdf ert xcv sdf rwer hfd dfg cvb rwf afb dfh jgh bmn lgh rty gfds cxv xcv xcs vdas fdf fgd cv sdf tert sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf shasha9178 shasha9178 shasha9178 shasha9178 shasha9178 liflif2 liflif2 liflif2 liflif2 liflif2 liblib3 liblib3 liblib3 liblib3 liblib3 zhazha444 zhazha444 zhazha444 zhazha444 zhazha444 dende5 dende denden denden2 denden21 fenfen9 fenf619 fen619 fenfe9 fe619 sdf sdf sdf sdf sdf zhazh90 zhazh0 zhaa50 zha90 zh590 zho zhoz zhozh zhozho zhozho2 lislis lls95 lili95 lils5 liss9 sdf0ty987 sdft876 sdft9876 sdf09876 sd0t9876 sdf0ty98 sdf0976 sdf0ty986 sdf0ty96 sdf0t76 sdf0876 df0ty98 sf0t876 sd0ty76 sdy76 sdf76 sdf0t76 sdf0ty9 sdf0ty98 sdf0ty987 sdf0ty98 sdf6676 sdf876 sd876 sd876 sdf6 sdf6 sdf9876 sdf0t sdf06 sdf0ty9776 sdf0ty9776 sdf0ty76 sdf8876 sdf0t sd6 sdf06 s688876 sd688 sdf86